Introducing a new way to review your PRs.

Read the announcement

floci-io / floci

Light, fluffy, and always free - The AWS Local Emulator alternative

View on GitHub

38 documents · Updated Nov 23, 2026

docs / svc-databases-and-cache

Databases and caches

Floci provides AWS-shaped control planes for relational databases, SQL over HTTP, caches, document stores, and graph stores. Each service keeps a durable resource description and can connect that description to a local engine in Docker. This separates resource management from data reachability: a resource can exist while its engine is unavailable. Resource records use the shared storage backend model. Network placement and security-group inputs come from EC2 and networking. Container startup follows the wider container orchestration model and client endpoints follow request routing and protocols. Redshift is another data service with its own page.

Service map

Service roles

The control plane manages resource identity, settings, relationships, and lifecycle state. The data plane carries database, cache, document, or graph traffic to a local engine when one is available.

ServiceProduct roleLocal engineClient path
RDSRelational instances and clustersPostgreSQL, MySQL, MariaDB, or SQL Server containerEngine protocol through an RDS authentication proxy
RDS DataSQL access to RDS over HTTPJDBC connection to an RDS backendJSON over HTTP
ElastiCacheRedis, Valkey, and Memcached resourcesRedis-compatible or Memcached containerRESP through a cache proxy or direct Memcached endpoint
MemoryDBRedis-compatible durable cache clustersRedis-compatible containerRESP through a MemoryDB proxy
DocumentDBMongoDB-compatible clusters and instancesMongoDB containerPublished MongoDB host and port
NeptuneGraph clusters and instancesGremlin Server or Neo4j containerGremlin or Bolt through a TCP relay

RDS keeps the API engine name separate from the local engine family. This lets an AWS-facing resource keep its requested identity while the local data path uses a supported engine.

References: src/…/RdsService.java• L107-112 src/…/RdsService.java• L180-211 src/…/ElastiCacheService.java• L76-120

Resource lifecycle

Control-plane lifecycle

The control plane accepts create, describe, modify, tag, and delete requests. It validates related resources such as subnet groups, parameter groups, security groups, keys, secrets, users, and ACLs before it changes a record or starts a backend.

Create operations reserve the resource identity for the full provisioning attempt. This prevents a retry from starting a second backend before the first attempt ends. If a real backend fails, the service removes its partial runtime state instead of publishing an endpoint that cannot serve data.

The common create path is:

flowchart LR
    A[SDK or CLI request] --> B[Query or JSON interface]
    B --> C[Resource validation]
    C --> D[Persist resource model]
    C --> E[Start local engine when enabled]
    E --> F[Wait for backend readiness]
    F --> G[Start proxy or relay]
    G --> H[Return AWS-shaped endpoint]
    D --> H

RDS, MemoryDB, DocumentDB, Neptune, and ElastiCache can retain metadata when Docker is unavailable. Such a resource can be described, but its data endpoint cannot serve traffic until the backend path is available. A real backend failure is different from a missing Docker daemon: the service reports a failure or rolls back the create instead of hiding the engine error.

RDS create claims are scoped by account, Region, and resource name. ElastiCache also claims IDs across replication groups and standalone cache clusters. These claims protect the shared endpoint and container names while provisioning is still in progress.

References: src/…/RdsService.java• L505-516 src/…/RdsService.java• L747-764 src/…/ElastiCacheService.java• L354-395 src/…/RdsContainerManager.java• L180-237

Data-plane connections

An authentication proxy is a local listener that presents the endpoint stored or derived by the control plane. It checks the client boundary when the protocol requires it. It then opens a session to the current backend address and relays the native protocol.

Connection pathBoundary behaviorCredential or protocol source
RDSHandles engine login, supported IAM, and TLS negotiation before relayMaster credentials, backend users, or an RDS SigV4 token
ElastiCacheReads Redis AUTH or authenticated HELLO before relayGroup token, attached user, or ElastiCache IAM token
MemoryDBReads Redis AUTH or authenticated HELLO and checks the ACLACL user password or IAM token
NeptuneDoes not inspect the graph protocolGraph session is relayed after resource checks
DocumentDBHas no auth proxyClient uses the current published MongoDB host and port

Each new RDS connection resolves the current backend address. A container can therefore restart or move without changing the public listener or the resource identity. The proxy also takes a backend lease for each connection, which keeps an auto-paused RDS backend awake for the session.

References: src/…/RdsAuthProxy.java• L21-49 src/…/RdsAuthProxy.java• L275-350 src/…/RdsContainerManager.java• L619-632

Relational database services

RDS

RDS models standalone database instances and shared database clusters. An instance owns a backend when it is standalone. A cluster owns one shared backend, and member instances refer to that runtime. The persisted records retain placement, storage, backup, maintenance, encryption, access, tags, snapshots, replicas, global-cluster membership, roles, events, and proxy relationships.

Cluster endpoints are views over the member topology. Writer and reader endpoints follow the saved writer role and current member set. Custom endpoints persist a member rule and apply it to the current cluster members. Failover changes the view without changing the custom endpoint's stored intent.

Read replicas are point-in-time copies in this local system. A replica inherits source settings at creation, but later source writes do not stream to it. Promotion removes the source link and makes the replica standalone. Snapshot and point-in-time restore create a new resource and load saved database data into its backend.

Modify operations update the stored description and the local backend for supported fields. Storage can grow but cannot shrink. Major engine-version changes require explicit permission. RDS also exposes regional CA certificates, managed master-user secrets, database logs, events, lifecycle notifications, asynchronous snapshot exports, and resource-scoped tag and authorization lookups.

The public endpoint is separate from the current container endpoint. The public listener stays on the resource's proxy port, while each new session resolves the current backend host and port. This allows a container to restart without changing the database identity or the endpoint clients receive. Persisted cleanup markers let a later retry remove a backend whose earlier start or stop failed before the runtime was fully published.

RDS rebuilds clusters, instances, and RDS proxies from saved records when the process starts. The saved resource remains the source of identity even when the local runtime must be recreated. A cluster model records the writer member explicitly, with older records falling back to the first member.

References: src/…/RdsService.java• L510-516 src/…/RdsService.java• L749-764 src/…/RdsService.java• L767-816 src/…/RdsContainerManager.java• L531-666

Blue/green deployments

An RDS blue/green deployment is a persisted pair of database instances used to prepare a change before moving production identity to the new instance. Creation copies the source data into a green instance and records the source, target, tasks, and switchover state.

The deployment flow is:

flowchart LR
    A[Blue source instance] --> B[Create green copy]
    B --> C[Apply target settings]
    C --> D[Available deployment]
    D --> E[Switchover]
    E --> F[Green keeps blue identity]
    E --> G[Blue moves to old identity]

Switchover exchanges the instances' endpoint and identity roles. The green instance takes the blue identifier, ARN, endpoint, and tags, so clients can reconnect to the same address. The former blue instance remains available under a new identity.

References: src/…/RdsService.java• L635-666 src/…/RdsContainerManager.java• L634-666

Aurora Serverless v2 auto-pause

Aurora Serverless v2 auto-pause links a cluster's zero minimum capacity to the shared RDS backend. A cluster can pause only when its members are available, every member uses db.serverless, and no global database or RDS DB proxy target blocks the pause.

Client and internal database work takes a backend lease. The lease resumes a paused backend when needed and keeps it awake until the operation ends. RDS proxy connections, RDS Data calls, snapshot work, restore work, and password changes use this boundary.

References: src/…/RdsContainerManager.java• L691-719 src/…/RdsService.java• L210-230

RDS Data

RDS Data exposes SQL through JSON HTTP calls instead of a database wire protocol. It resolves the exact local RDS ARN in the request Region, restores a missing backend when possible, reads the resource credentials, and opens a direct JDBC connection to the current backend.

The service supports one-shot SQL, batch SQL, and transactions. A transaction stays bound to its resource ARN, database, and Region until commit, rollback, or expiry. It also holds the backend lease for that period, so an auto-paused cluster stays awake. An idle transaction rolls back and closes after its time limit.

sequenceDiagram
    participant C as Data API client
    participant H as RDS Data service
    participant R as Resource resolver
    participant G as Backend lease
    participant J as JDBC connection
    participant E as RDS engine
    C->>H: JSON request with resource ARN and SQL
    H->>R: Resolve ARN and Region
    R-->>H: Existing or restored backend target
    H->>G: Acquire backend lease
    G-->>H: Running backend
    H->>J: Open JDBC connection
    J->>E: Execute SQL
    E-->>J: Rows or update count
    J-->>H: JDBC result
    H->>G: Release lease
    H-->>C: Data API JSON response

RDS Data supports PostgreSQL, MySQL, and MariaDB. It does not use the RDS TCP authentication proxy and does not support SQL Server on this path.

References: src/…/RdsService.java• L505-516 src/…/RdsAuthProxy.java• L275-350

Cache services

ElastiCache

ElastiCache represents Redis or Valkey replication groups, standalone Redis or Valkey clusters, Memcached clusters, and serverless caches. Its control plane manages topology, users, user groups, subnet and parameter groups, tags, encryption, snapshots, IAM token validation, and log delivery state.

Replication groups can use one node or cluster mode. Cluster mode records shards, primary and replica members, slot ranges, and node endpoints. The service forms that topology before it publishes the configuration endpoint because clients need slot discovery and redirects. Memcached reports the requested node count while its local data path uses one backend container.

ElastiCache separates transport encryption from client authentication. Transport can be unencrypted, preferred, or required. Transport encryption alone does not select an authentication mode. A compatible user group must be attached before its users can connect, and user-group access requires in-transit encryption.

The cache proxy keeps frontend credentials out of the backend ACL. It creates private backend identities with the user's access rules and blocks commands that would change topology or bypass the proxy's access boundary. It also inspects later AUTH and HELLO commands while passing other RESP traffic through.

Manual snapshots capture RDB data for a cluster-mode-disabled replication group. A new group is seeded from that snapshot before its record and proxy become visible. Serverless caches have a durable product record and a hidden backing cache cluster whose endpoint and live data path are refreshed during describe and restore operations.

ElastiCache rebuilds persisted Redis, Valkey, and standalone cache-cluster data paths after a process restart. The cache keyspace is not part of the resource record, so a restored cache starts empty unless a snapshot archive seeds it. A failed restore keeps the control-plane record but clears the unusable endpoint and reports a failure state. A log delivery configuration records the requested destination and becomes an error state when a named CloudWatch Logs group does not exist; Floci does not ship the cache logs.

References: src/…/ElastiCacheService.java• L354-395 src/…/ElastiCacheService.java• L438-523 src/…/ElastiCacheService.java• L625-650 src/…/ElastiCacheService.java• L805-877

MemoryDB

MemoryDB models Redis-compatible clusters whose access rules come from an access control list, or ACL. The ACL names users and determines whether the cluster is open, password-protected, or IAM-protected. A cluster points to the ACL, so an ACL change can change the cluster's effective access rule.

The control plane exposes cluster, user, ACL, and tag actions. It synthesizes the built-in open-access ACL and default user for each account. New users need password or IAM authentication and an access string. Custom ACLs must include the default user.

When Docker is enabled, a Redis-compatible container and RESP proxy provide the data path. The proxy resolves the supplied user through the cluster ACL, accepts AUTH or authenticated HELLO, and then relays the session. For custom ACLs it applies the user's access string to a private backend identity. An open-access cluster is a direct relay.

MemoryDB persists the cluster's account, Region, ACL link, endpoint view, proxy port, tags, and optional volume identity. Runtime container coordinates are not durable. On restore, the service reserves the saved port, starts a new Redis-compatible backend when Docker is reachable, and recreates the proxy. If Docker is unavailable, the cluster can still reach available for metadata calls while its data endpoint has no live backend. A real container or readiness failure triggers cleanup of the proxy, container, storage, endpoint, and owned port. The backend is accepted only after a RESP PING receives PONG.

References: src/…/MemoryDbContainerManager.java• L74-110 src/…/MemoryDbContainerManager.java• L143-203 src/…/MemoryDbContainerManager.java• L213-250

Document and graph services

DocumentDB

DocumentDB models MongoDB-compatible clusters and member instances. The resource descriptions carry placement, encryption, backup, maintenance, parameter-group, security-group, tag, ARN, and member information.

The service waits for the MongoDB backend and publishes its current mapped host and port in cluster and instance descriptions. There is no proxy in front of this path. Clients must read the endpoint from the latest describe response. DocumentDB shares the RDS-family response shape and security-group checks, but resource lookup remains owned by the DocumentDB service.

References: src/…/DocDbService.java• L194-264

Neptune

Neptune models graph clusters and member instances through the RDS-family cluster and instance shape. The configured graph type selects a Gremlin Server container or a Neo4j container with Bolt enabled. The cluster and its members share the cluster endpoint and proxy port.

Neptune publishes a protocol-neutral TCP relay in front of the backend. The relay does not parse graph messages or broker graph credentials. Gremlin WebSocket traffic and Neo4j Bolt traffic pass through after resource checks. Backend readiness uses an HTTP response for Gremlin Server or a non-zero Bolt handshake response for Neo4j.

Neptune scopes runtime identity by account, Region, and cluster. If Docker is not reachable, Neptune keeps the metadata record and reports the cluster as available without a usable graph path. If a real container or readiness check fails, the service removes the partial backend and relay.

References: src/…/NeptuneContainerManager.java• L66-105 src/…/NeptuneContainerManager.java• L104-149 src/…/NeptuneContainerManager.java• L231-289

Persisted runtime

Resource models

The persisted model is the durable description of a resource. It carries identity, ARN, Region-sensitive settings, endpoint data, access and encryption choices, tags, relationships, and the topology needed to rebuild or clean up a data path. Runtime handles and active sockets remain outside that durable description.

Resource familyDurable relationship
RDSCluster members share a cluster runtime; replicas link source and copy; global clusters hold regional members; proxies hold targets and endpoints; snapshots point to a source and saved data; blue/green deployments pair source and target instances
ElastiCacheReplication groups record members, shards, slot ranges, topology, transport security, member numbering, reported primary, and log delivery state; snapshots point to a group and saved cache data; users and groups record authentication and membership
MemoryDBA cluster names an ACL, and the ACL names users; users and ACLs retain account, Region, ARN, and tag identity
DocumentDBA cluster records its member instance identifiers
NeptuneA cluster records member identifiers, endpoint data, and persisted cleanup coordinates

RDS records both the API engine identifier and the local engine choice. It also persists storage identity, managed secret links, scaling settings, CA certificate choice, associated roles, endpoint rules, and backend cleanup state. ElastiCache users, groups, snapshots, and log delivery configurations persist the control-plane data needed for identity and status checks after restart.

Container handles, live sockets, active proxy listeners, port reservations, and other process-local objects are runtime state. RDS rebuilds these objects from persisted records and durable database volume identity. MemoryDB can persist a volume identity when durable storage is enabled, but not active container coordinates. Cache contents are not restored from the cache resource model; an ElastiCache snapshot is the separate exception because its saved archive can seed a new group.

References: src/…/RdsService.java• L180-211 src/…/RdsContainerManager.java• L531-666 src/…/ElastiCacheService.java• L87-120 src/…/MemoryDbContainerManager.java• L147-168

Container-backed engines

Container managers turn a resource model into a local database or cache engine. They choose an image, connect the engine to the configured Docker network, map a backend port, wait for an engine-specific readiness response, and return a runtime handle to the owning service.

BackendReadiness signalPersistence model
RDSEngine-specific server readinessDurable Docker volume identity is retained for a new container
Redis or ValkeyRESP PINGResource metadata rebuilds topology; cache contents are separate
MemcachedText version requestResource metadata rebuilds the backend shape
Neptune GremlinHTTP responseContainer is per cluster
Neptune Neo4jNon-zero Bolt handshake responseContainer is per cluster

The services distinguish an unreachable Docker daemon from a backend that starts and fails its own readiness check. The first can leave metadata available for later recovery. The second must not publish a usable endpoint. RDS also treats a database that rejects its parameter-group settings as an incompatible backend rather than a healthy one. RDS retains cleanup identity when a start or cleanup fails so a later retry can remove stale containers before it claims the same storage.

References: src/…/RdsContainerManager.java• L180-237 src/…/RdsContainerManager.java• L325-500 src/…/ElastiCacheService.java• L438-523 src/…/MemoryDbContainerManager.java• L143-250 src/…/NeptuneContainerManager.java• L104-149 src/…/NeptuneContainerManager.java• L231-289

Connection proxies

Connection proxies provide a stable AWS-shaped endpoint while a local engine uses a mapped host and port. They own the authentication boundary, choose backend credentials when needed, and relay the native protocol after the handshake.

RDS has engine-aware handlers for PostgreSQL and MySQL or MariaDB, plus a generic bridge for SQL Server. PostgreSQL can terminate client TLS, validate password or IAM access, hand an IAM session to the named database role, and apply startup settings only after that role owns the session. The same listener shape supports a native database endpoint and a standard RDS DB proxy endpoint. Each new connection resolves the target's current backend address.

ElastiCache and MemoryDB share a Redis handshake boundary. The shared proxy accepts AUTH and authenticated HELLO, validates credentials through the service-specific control plane, and then becomes a byte relay. It checks later sign-in commands and rewrites accepted credentials to private backend credentials. ElastiCache can use clear, preferred-TLS, or required-TLS transport.

Neptune uses a protocol-neutral relay. DocumentDB has no relay. A proxy is therefore part of the data path, not proof that the persisted resource has a running backend.

References: src/…/RdsAuthProxy.java• L57-189 src/…/RdsAuthProxy.java• L275-350 src/…/RdsContainerManager.java• L619-632

Change checklist

When these files or sections are changed, remember to consider these:

  • If an RDS engine changes, keep the API engine identity, local backend choice, wire handler, RDS Data JDBC choice, and endpoint output aligned.
  • If RDS container recovery changes, keep storage identity, Docker volume names, retained cleanup records, proxy startup, and status reconciliation aligned.
  • If RDS authentication or endpoint binding changes, keep password rotation, IAM token checks, TLS trust, resource identity, live listener updates, and current backend resolution aligned.
  • If PostgreSQL handshake handling changes, keep client TLS, backend protocol state, IAM role selection, startup settings, password validation, and post-auth session checks aligned.
  • If RDS instance or cluster settings change, keep create fields, modify-time deltas, stored defaults, snapshots, replicas, restore behavior, and VPC security-group validation aligned.
  • If RDS blue/green behavior changes, keep source claims, green copy settings, endpoint and ARN exchange, container runtime identities, deployment status, and delete rules aligned.
  • If RDS Data request or result fields change, update exact ARN and Region checks, backend recovery, lease scope, transaction identity, parameter binding, and result shape together.
  • If ElastiCache topology changes, keep shards, slot ranges, member numbers, primary role, member endpoints, configuration endpoints, proxy ports, formation, status, and restore behavior aligned.
  • If ElastiCache authentication changes, keep transport encryption separate from authentication mode, user-group association, proxy validation, private backend identity setup, command restrictions, and later sign-in handling aligned.
  • If ElastiCache snapshots, log delivery, or restore changes, keep RDB archive storage, destination status, restore-before-publish behavior, regional identity, empty-cache semantics, endpoint clearing, and cleanup aligned.
  • If Redis authentication or backend ACL handling changes, update ElastiCache and MemoryDB control-plane rules, frontend handshake checks, backend user setup, command restrictions, and open-session refresh together.
  • If MemoryDB cluster persistence or recovery changes, keep account-Region keys, ACL resolution, saved proxy ports, volume identity, Docker-unavailable behavior, readiness checks, and rollback cleanup aligned.
  • If Neptune backend selection or readiness changes, update the container image, protocol probe, relay path, endpoint shape, and rollback cleanup together.
  • If persisted models change, keep durable identity distinct from process-local handles, endpoint fields, port ownership, and restart recovery.

Important failure modes

TriggerConsequenceGuard
Docker is unavailable during a metadata createDescribe calls succeed, but data connections failKeep control-plane state separate from backend reachability
A backend fails its engine readiness checkThe service must not expose a usable data pathRequire the engine-specific readiness signal before publishing access
A proxy port is unavailableThe resource cannot accept connections at its reported endpointReserve ports and use the endpoint returned by the service
An RDS proxy uses a stale container host or port after restartNew sessions fail while the public listener remains openResolve the current backend endpoint for each outbound session
An RDS IAM token uses an old endpoint or resource identityThe proxy rejects the session before database loginGenerate the token from the current endpoint and resource identity
A database remains an RDS DB proxy targetDirect deletion is refusedDeregister the target before deleting the database
A PostgreSQL IAM session changes session_authorization after loginThe client can regain privileges from the master-backed sessionInspect server status messages and terminate the session on a role change
A cache access string uses unsupported ACL selectorsThe connection cannot establish a safe backend identityReject unsupported ACL features instead of broadening access
A clear-text ElastiCache session remains after transport becomes requiredThe client keeps using a transport the resource no longer allowsDrop unencrypted sessions when required transport is applied
A cache user is not attached to its group or ACLRESP authentication failsAssociate the user before connecting
A cluster-mode cache loses a member or proxySlot discovery and redirects failTreat the full topology as one provisioning unit
An ElastiCache data-plane restore failsThe resource reports a failed state without a usable endpointClear the endpoint, stop partial containers and proxies, and release ports
An ElastiCache cache restarts successfullyThe resource is available but its previous keyspace is absentTreat the persisted record as topology only unless a snapshot seeds it
A MemoryDB readiness probe does not receive PONGA failed Redis backend is not safe to publishWait for the RESP readiness signal and roll back the partial backend
A Neptune readiness probe does not match the selected graph engineA failed backend can be published or a healthy one rejectedPair Gremlin HTTP and Neo4j Bolt probes with the selected image
A DocumentDB client assumes a fixed MongoDB portThe client misses the mapped endpointRead host and port from the latest describe response
A persisted record contains stale process-local fieldsMetadata survives while new connections failRebuild active runtime state from durable identity and current endpoints

Key files

FileWhy to read it
src/…/RdsService.javaRDS lifecycle, relationships, placement, restore, runtime recovery, resource lookup, and proxy binding
src/…/RdsContainerManager.javaRelational container lifecycle, durable storage, readiness, cleanup, endpoint resolution, and leases
src/…/RdsAuthProxy.javaRDS listener lifecycle, backend resolution, engine dispatch, authentication boundary, and backend leases
src/…/RdsDataService.javaSQL execution, transactions, backend leases, recovery, and Data API results
src/…/ElastiCacheService.javaCache topology, provisioning, ports, authentication, encryption, snapshots, restore, and log delivery state
src/…/AbstractRedisAuthProxy.javaShared Redis handshake, later sign-in checks, transport handling, IAM lifetime, and relay
src/…/MemoryDbService.javaMemoryDB clusters, ACLs, users, provisioning, persistence, recovery, and authentication relationships
src/…/MemoryDbContainerManager.javaMemoryDB container identity, volume attachment, readiness, Docker handling, and cleanup
src/…/DocDbService.javaDocumentDB resource model, backend lifecycle, endpoint publication, and member relationships
src/…/NeptuneContainerManager.javaNeptune backend selection, Docker handling, protocol readiness, and cleanup
src/…/NeptuneProxyManager.javaActive Neptune relay registry and cluster relay lifecycle