A reference implementation on AWS, service by service
Every AWS service the engine uses, what it does, which part of the engine runs in it and whether that part is Rust or a managed service; a request traced through the real services; the template; and the cost model with its arithmetic, down to what one small project adds.
On this page
- The services
- Where the Rust is, and where the logic is
- From crates to functions to services
- One request through the real services
- Limits and settings in one place
- The template
- Postgres: which one, and why
- The cost model
- Prices used
- An idle deployment
- Unit costs
- Two self-hosted examples
- One small project, at its usage
- What changed from the system this comes from
- Next
Deployment shapes says the engine can run as functions on AWS. This page is that deployment with the names on: which AWS service does what, where the Rust code runs, where the engine’s logic lives, what each service is limited to, and what it costs. It is the deployment the templates sypnia-db.yaml and sypnia-aws.yaml create, and the one Sypnia Cloud runs Cloud.
The services
Nine AWS services. One of them, Lambda, runs the engine’s code, as three functions. The last column is the answer to «is this Rust, or is this Amazon?».
| AWS service | What it does here | Which part of the engine | Rust code, or managed |
|---|---|---|---|
| Amazon CloudFront | The one HTTPS address. Sends /v1/ingest/*, /v1/otlp/* and the SDK’s two script files (/v1/sdk.js, /v1/sdk-recorder.js) to the ingest function and everything else to the API function. Caches only those two files | None. It forwards | Managed. Configuration: four path rules |
AWS Lambda, function sypnia-ingest | Receives what SDKs send | Ingest: the seven gates, then the batch goes to the queue; replay chunks and snapshots go to the Bucket | Rust: the sypnia binary with SYPNIA_ROLE=ingest |
AWS Lambda, function sypnia-worker | Does all the work that is not a request | The worker: writing segments, the Fast path, the Roll-up, the agent’s jobs, Alerts and webhooks, uptime checks, retention, Parquet | Rust: the same binary with SYPNIA_ROLE=worker |
AWS Lambda, function sypnia-api | Answers people and coding agents | The API, the MCP server and the Console | Rust: the same binary with SYPNIA_ROLE=api |
| Amazon SQS, the intake queue and its dead-letter queue | Holds validated batches until the worker has written them; parks the ones that failed five times | None. It is the buffer a function cannot keep in memory | Managed. Configuration: retention, visibility timeout, maxReceiveCount |
| Amazon EventBridge Scheduler | Wakes the worker every minute | None. The worker decides what is due | Managed. Configuration: rate(1 minute) |
| Amazon S3 | The Bucket: segments, per-session files, replay chunks, snapshots, source maps, Parquet | None. Keys are built by the engine; retention is the engine’s daily job | Managed. Configuration: private, encrypted, one rule for unfinished uploads, CORS for replay links |
| Amazon RDS for PostgreSQL | Postgres: the ledger, problems, numbers, the session index, alerts, jobs. One instance in a stack of its own, sypnia-db; the engine has its own database and role in it | None. No stored procedure, no trigger, no extension | Managed. Or any Postgres 15 or later of yours |
| AWS Systems Manager Parameter Store | Holds the database passwords as SecureStrings: the instance’s master password and the engine’s own | None | Managed. Standard parameters |
| Amazon CloudWatch | A log group per function, kept 30 days; three alarms | None. The alarms watch the engine from outside | Managed. Configuration: three thresholds |
| AWS IAM | One role per function, each with the least it needs | None | Managed |
Not used, on purpose: no load balancer, no API gateway, no container cluster, no NAT gateway, no stream, no cache, no search service, no workflow service, no second database.
Cloud Sypnia Cloud serves its MCP server at the root of mcp.sypnia.com, not at /mcp. The same distribution carries mcp.sypnia.com as an alternate domain name, and one CloudFront Function on its default behaviour (viewer request) rewrites / on that host to /mcp, so the request reaches sypnia-api as on any engine; nothing else is rewritten, so /.well-known/… at the root stays free. The function runs on the API’s requests only, at USD 0.10 per million.
| Sypnia engineOpen source, self-hosted | Sypnia CloudPaid service, with a free tier | |
|---|---|---|
| None. Alerts are recorded and sent to your webhook; the guides show how to send e-mail from it. | Amazon SES: alert e-mails and the daily summary. | |
| AI provider | Yours, off until you set a key. The worker calls it over HTTPS. | OpenRouter, with settings that forbid providers from keeping or training on the data. |
| Accounts, billing, the app, the GitHub App | Not in the engine. | The private app. It is a client of the engine's public API, like your own tools; it has its own database and adds no logic to the engine. |
Where the Rust is, and where the logic is
- Amazon CloudFront is the address. It sends
/v1/ingest/*,/v1/otlp/*,/v1/sdk.jsand/v1/sdk-recorder.jstosypnia-ingest, and everything else tosypnia-api. sypnia-ingest(AWS Lambda, 256 MB, 10 s, 40 copies) is Ingest: the seven gates. It sends each batch to the queue, and replay chunks and snapshots straight to S3.- Amazon SQS holds the intake queue and, after 5 deliveries, the dead-letter queue (14 days).
sypnia-worker(1,024 MB, 15 min, 3 copies) writes segments and runs the Fast path, the Roll-up, the agent, alerts, uptime and retention. It invokes itself for agent jobs.- Amazon EventBridge Scheduler wakes the worker every minute.
- Amazon S3 is the Bucket.
- Amazon RDS for PostgreSQL is Postgres, in its own stack,
sypnia-db. sypnia-api(512 MB, 30 s, 20 copies) is the API, the MCP server and the Console. It reads Postgres and signs links to S3.
Read this diagram as text
Inside the frame «AWS account · us-east-1 · stack: sypnia» the three Lambda functions are lit and tagged «Rust»: they are the engine. Everything else is a managed service. Your app (SDK) reaches sypnia-ingest through CloudFront; you, your coding agent and your CI reach sypnia-api the same way. Ingest calls SendMessage; the queue delivers up to 10 seconds of messages to the worker; the worker writes segments, session files and Parquet to S3, and the ledger, problems, numbers and jobs to Postgres. Around it: AWS Systems Manager Parameter Store (the database passwords), Amazon CloudWatch (logs and 3 alarms) and AWS IAM (one role per function). Outside the frame, the worker calls the AI provider (yours; on Sypnia Cloud, OpenRouter) and your webhook. Sypnia Cloud only: Amazon SES and the private app.
Three statements, each of which you can check in the template and in the code:
- Everything inside the three functions is the engine, and the engine is Rust. The functions run the same file,
sypnia, built for arm64 and started by Lambda as itsbootstrap. There is no Node, Python or Java runtime in the deployment, and no second program. - AWS services move and hold bytes. CloudFront forwards a request. SQS keeps a message. S3 keeps an object. Postgres keeps rows. The scheduler sends one fixed JSON document a minute. None of them inspects an event.
- No logic lives in a service’s configuration. What the template configures is numbers and names: four path rules, a retention, a visibility timeout, the
5of the dead-letter rule, a rate, three alarm thresholds, the roles. There is no request-mapping template, no rule with a filter, no code at the edge, no bucket notification, no stored procedure, no trigger, no workflow definition. Retention is not even a bucket lifecycle rule: it is the engine’s daily job, so it is the same on any S3-compatible store.
That third statement is what makes the engine portable. Replace SQS by memory and Lambda by a process, and you have the one-process shape, with the same code deciding the same things.
From crates to functions to services
- The crates: all the logic. The binary crate
sypnia(main,lambda,Engine) becomes all three functions throughmain → lambda::run(role);sypnia-store,sypnia-db,sypnia-fingerprintandsypnia-coreare linked into all three. - The functions: the same binary, started with
SYPNIA_ROLE=ingest,workerorapi. - The AWS services, and on each one the permission of the function that touches it.
Read this diagram as text
Which crate runs where: sypnia-ingest runs in the ingest function (the gates, the send) and in the worker (the queue’s other end: writing segments); sypnia-pipeline and sypnia-alerts run in the worker; sypnia-agent runs in the worker (jobs) and in the API (the prompt); sypnia-api runs in the API function. What each function may touch: the ingest function is invoked by CloudFront, may send to SQS and may only put to S3. The worker receives, deletes and delays SQS messages, is woken by the Scheduler every minute, reads and writes S3 and RDS, and calls the AI provider and your webhook. The API function is invoked by CloudFront, reads RDS and makes the writes of the API, and reads S3 and signs links. The left column is all the logic; the right column has none.
| Crate | Runs in | Reaches |
|---|---|---|
sypnia (the binary): main, lambda, Engine | All three functions | The Lambda runtime |
sypnia-ingest | sypnia-ingest: the gates and the send. sypnia-worker: the queue’s other end, which writes segments | SQS, S3 |
sypnia-pipeline | sypnia-worker | S3, Postgres |
sypnia-agent | sypnia-worker: the jobs. sypnia-api: the prompt | S3, Postgres, the AI provider |
sypnia-alerts | sypnia-worker | Postgres, your webhook, the addresses of your uptime checks |
sypnia-api | sypnia-api | Postgres, S3 (read, and signing links) |
sypnia-store, sypnia-db | All three | S3; Postgres |
sypnia-fingerprint, sypnia-core | All three | Nothing: no I/O |
The functions share one entry point. It is the main of Deployment shapes; these are the lines that matter here. Notice that the role is the only thing that differs between the three functions, and that it is read from the environment the template sets.
// Bucket, Postgres, the AI provider (or none), the alert sinks. Built once, shared by everything.
let engine = match Engine::connect(config.clone()).await {
Ok(engine) => Arc::new(engine),
Err(error) => return fail(4, &error),
};
// Inside AWS Lambda the runtime sets this variable and there is no command line.
if std::env::var_os("AWS_LAMBDA_RUNTIME_API").is_some() {
return exit(lambda::run(engine, config.role).await); // SYPNIA_ROLE: ingest | worker | api
}One request through the real services
The failed payment of the overview, with the service that carries each step, its time budget, its limit and what happens when that service fails. The failure column is a summary; What happens when something fails has every case.
| # | Step | Service | Budget | The limit that applies | If it fails |
|---|---|---|---|---|---|
| 1 | The browser sends POST /v1/ingest/events | CloudFront → Lambda sypnia-ingest | 50 ms warm; 300 ms for a cold function | Body: 2 MiB after decompression (the engine’s), 6 MB (Lambda’s). 10 s. 40 copies; beyond them the address answers 429 | The SDK keeps the batch and retries with the same batch_id |
| 2 | Ingest sends the validated batch | SQS SendMessage | 20 ms | 256 KiB a message; a batch over 192 KiB compressed goes to S3 and the message names it | 503; the SDK retries |
| 3 | Ingest answers 200 | Lambda → CloudFront | — | — | — |
| 4 | The queue hands the batch to the worker | SQS → Lambda sypnia-worker | Up to 10 s | 500 messages or 6 MB a delivery. At most 2 copies at once. Visibility 15 min | Delivered again after 15 s, 1 min, 5 min, 15 min; then the dead-letter queue |
| 5 | The worker writes the segment | S3 PutObject | 300 ms | 4 MiB a segment, before compression | The message is not deleted; step 4 repeats |
| 6 | The worker writes the ledger row, scans the segment, writes the problem, its alert and its job | RDS for PostgreSQL, one transaction | 50 ms; 5 s for the scan | 3 connections per worker copy | The segment stays leased 2 minutes, then another try; 5 tries, then quarantine |
| 7 | The worker calls itself with the job | Lambda Invoke, asynchronous | 100 ms | Lambda’s own retries off: the job row is the retry | The minute tick finds the row |
| 8 | The agent reads maps and the session, calls the model, writes the sentence | S3 GetObject; HTTPS to the AI provider; Postgres | 60 s | 15 min for the function; 3 tries for the job | The alert leaves on time without the sentence; analysis.status: failed |
| 9 | The alert is released to your webhook | HTTPS from the worker | 10 s | 7 tries over 21 hours | The alert is recorded all the same |
| 10 | Every minute: one pass | EventBridge Scheduler → Lambda sypnia-worker | 1 s when idle | 3 copies shared with steps 4, 7 and 8; the queue never takes the third | The next tick does it |
| 11 | Your coding agent calls the MCP tool problem | CloudFront → Lambda sypnia-api → Postgres | 300 ms | Answer: 6 MB (Lambda’s); 30 s; 20 copies; 2 connections per copy | 503 with Retry-After: 2 |
| 12 | You open the replay | sypnia-api signs links; the browser reads S3 directly | 300 ms for the links | A link lives 15 minutes; chunks never pass through a function | 503; the list of problems still works |
Limits and settings in one place
| Where | Setting | Value | Why this value |
|---|---|---|---|
sypnia-ingest | Memory, time limit, copies | 256 MB, 10 s, 40 | It only checks and forwards. 40 copies at 50 ms accept about 800 batches a second |
sypnia-worker | Memory, time limit, copies | 1,024 MB, 15 min, 3 | Two projects rolled at once (2 × 256 MB), the source-map cache, room. The daily job may need the 15 minutes. The queue may use 2 copies, so the third is always there for the minute tick and agent jobs |
sypnia-api | Memory, time limit, copies | 512 MB, 30 s, 20 | A session’s detail is built in memory, inside a 4 MB budget |
| All functions | Architecture, runtime | arm64, provided.al2023 | A native binary; no language runtime to start |
| All functions | Environment | Under 4 KB in all | Lambda’s limit. The engine needs about 12 settings |
| Intake queue | Retention, visibility, deliveries | 4 days, 15 min, 5 | See Reliability |
| Dead-letter queue | Retention | 14 days | The longest SQS allows |
| Queue → worker | Batch, window, answer | 500 messages or 6 MB, 10 s, failures reported per message | One bad message does not send the others back |
| Scheduler | Rate | Every minute | One schedule; daily and weekly work is started by the pass when due |
| Bucket | Encryption, access | At rest, private | Functions reach it through their roles; browsers through 15-minute signed links |
| Postgres | Connections | At most 89: 40 × 1, 20 × 2, 3 × 3 | Fits the smallest instance, which accepts about 100, with about 10 left for db-init and anything else on the instance |
| Alarms | Three | Dead-letter queue not empty; oldest message over 120 s for 3 minutes; worker failing in 3 of 5 minutes | They work when the engine does not |
The three copies of the worker are shared by the queue’s deliveries, the minute tick and agent jobs. The queue may use at most two of them (MaximumConcurrency: 2, the lowest SQS allows), so a burst of deliveries never holds back the minute tick. When all are busy, a new call waits: a message stays in the queue, an asynchronous call is held by Lambda. Nothing is lost; work is later. This is the first number to raise when lag_seconds grows, together with the database’s connections.
The template
The whole engine is one file, sypnia-aws.yaml, beside the database’s, sypnia-db.yaml. This excerpt is the part this page talks about: the three functions, the queue with its dead-letter rule, the schedule and one alarm. Left out: the distribution, the bucket, the roles written out one by one, the log groups, the other two alarms and the outputs. Names carry the stack’s name, so a development and a production stack fit one account. How to deploy it is in Deploy on AWS.
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Runtime: provided.al2023 # no language runtime: the package is the sypnia binary, named bootstrap
Handler: bootstrap
Architectures: [arm64]
CodeUri: { Bucket: !Ref CodeBucket, Key: !Sub "sypnia/${Version}/sypnia-lambda-arm64.zip" }
Environment:
Variables:
SYPNIA_ROOT_TOKEN: !Ref RootToken
SYPNIA_STORAGE_BUCKET: !Ref Bucket
SYPNIA_DATABASE_URL: !If # the instance of the sypnia-db stack, or a Postgres of yours
- SharedDb
- !Sub
- "postgres://${DatabaseUser}:${DatabasePassword}@${Host}:5432/${DatabaseName}?sslmode=require"
- Host: { "Fn::ImportValue": !Sub "${DatabaseStack}-Host" }
- !Ref DatabaseUrl
SYPNIA_INTAKE_QUEUE_URL: !Ref IntakeQueue # the queue stands in for the in-memory buffer
SYPNIA_INTAKE_DEAD_LETTER_QUEUE_URL: !Ref IntakeDeadLetterQueue # read by /v1/engine/status and sypnia doctor
Resources:
IngestFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-ingest"
MemorySize: 256
Timeout: 10
ReservedConcurrentExecutions: 40
FunctionUrlConfig: { AuthType: NONE } # reached through the distribution; the engine checks every key itself
Environment: { Variables: { SYPNIA_ROLE: ingest, SYPNIA_DATABASE_MAX_CONNECTIONS: "1" } }
Role: !GetAtt IngestRole.Arn # send to the queue, put objects; written out, not a SAM shortcut
ApiFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-api"
MemorySize: 512
Timeout: 30
ReservedConcurrentExecutions: 20
FunctionUrlConfig: { AuthType: NONE }
Environment: { Variables: { SYPNIA_ROLE: api, SYPNIA_DATABASE_MAX_CONNECTIONS: "2" } }
Role: !GetAtt ApiRole.Arn # read, and sign links to read and to upload source maps
WorkerFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-worker"
MemorySize: 1024
Timeout: 900
ReservedConcurrentExecutions: 3 # the queue takes at most 2; the tick always has one
Environment: { Variables: { SYPNIA_ROLE: worker, SYPNIA_DATABASE_MAX_CONNECTIONS: "3", SYPNIA_AUTO_MIGRATE: "true" } }
EventInvokeConfig: { MaximumRetryAttempts: 0 } # a job is a row in Postgres: the row is the retry
Role: !GetAtt WorkerRole.Arn # the bucket, both queues, invoking itself
Events:
Intake:
Type: SQS
Properties:
Queue: !GetAtt IntakeQueue.Arn
BatchSize: 500
MaximumBatchingWindowInSeconds: 10
FunctionResponseTypes: [ReportBatchItemFailures] # only the messages that failed come back
ScalingConfig: { MaximumConcurrency: 2 }
EveryMinute:
Type: ScheduleV2
Properties:
ScheduleExpression: rate(1 minute)
Input: '{"job":"pass"}'
IntakeQueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 900 # not shorter than the worker's time limit
MessageRetentionPeriod: 345600 # 4 days
ReceiveMessageWaitTimeSeconds: 20
SqsManagedSseEnabled: true
RedrivePolicy:
deadLetterTargetArn: !GetAtt IntakeDeadLetterQueue.Arn
maxReceiveCount: 5 # the fifth failed delivery is the last
IntakeDeadLetterQueue:
Type: AWS::SQS::Queue
Properties:
MessageRetentionPeriod: 1209600 # 14 days
SqsManagedSseEnabled: true
DeadLetterNotEmpty:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmDescription: Batches were set aside. Look at one, fix the cause, redrive.
Namespace: AWS/SQS
MetricName: ApproximateNumberOfMessagesVisible
Dimensions: [{ Name: QueueName, Value: !GetAtt IntakeDeadLetterQueue.QueueName }]
Statistic: Maximum
Period: 60
EvaluationPeriods: 1
Threshold: 0
ComparisonOperator: GreaterThanThreshold
TreatMissingData: notBreachingWhat wakes the worker is told apart by the shape of the event, in worker_event of Deployment shapes: { "Records": […] } is the queue, { "job": "pass" } is the schedule, { "job": { "agent": { "problem": "prb_8f3k2m9x4q7w" } } } is the worker calling itself.
Postgres: which one, and why
The reference uses Amazon RDS for PostgreSQL, one small instance in one availability zone, in a stack of its own: sypnia-db.yaml, stack sypnia-db. db.t4g.micro, Postgres 16, 20 GB of gp3 that grows by itself up to 100 GB, encrypted, TLS forced (rds.force_ssl), backups kept 7 days, deletion protection on, a snapshot when the stack is deleted.
- Its own stack, so the engine stack can be deleted and created again while the data stays.
- One instance, several databases. The engine gets its own database,
sypnia, and its own role,sypnia_engine, which owns that database and nothing else;scripts/deploy-aws.sh db-initcreates both with the master user, which nothing else uses. Another application gets its own database and role on the same instance, not a second instance. - When it runs short, resize it to
db.t4g.small: a change of instance class, with no migration. - Bring your own with the engine stack’s
DatabaseUrl; then the database stack is not needed.
| Option | Idle cost a month | Good | The price you pay |
|---|---|---|---|
RDS for PostgreSQL, db.t4g.micro (the reference) | 11.68 + 2.30 of disk | The cheapest managed Postgres on AWS; a fixed bill; plain Postgres | One zone: a failure of the instance is minutes of «receiving works, reading does not». About 100 connections |
| RDS, two zones (Multi-AZ) | Twice the instance and the disk | Fails over by itself in a minute or two | Twice the price for a database the Bucket can mostly rebuild |
| Aurora Serverless v2 | From 43.80: 0.5 capacity units × 0.12 × 730, plus storage and I/O | Grows and shrinks with load | Three times the idle cost. Scaling to zero does not fit: the minute tick would wake it every minute |
| A Postgres outside AWS (Supabase, Neon, your own) | 0 to 25 | You may already have it | Every query crosses the internet; their connection limits apply. Use a session-mode or direct connection, not a transaction pooler |
One connection string. The engine takes a single SYPNIA_DATABASE_URL, for every role. It must be a direct or session-mode connection: the engine prepares its statements and runs transactions of several statements, which a transaction-mode pooler breaks. Functions keep the total small instead: 1 connection per ingest copy, 2 per API copy, 3 per worker copy.
Secrets. The database passwords are SSM Parameter Store SecureStrings, not Secrets Manager secrets: /sypnia/db/master-password and /sypnia/engine/db-password. CloudFormation cannot create a SecureString, so scripts/deploy-aws.sh db-secrets does, with 48 generated hex characters written through a file only you can read and never printed. The database stack reads the master password with a {{resolve:ssm-secure:…}} reference, one of the few properties where CloudFormation allows it. A Lambda environment is not one of them, so scripts/deploy-aws.sh deploy reads the engine’s password from SSM and hands it to the engine stack’s parameter DatabasePassword, which is never echoed. db-init passes passwords to psql through its environment, never on a command line. The engine’s password, the root token, the AI key and the webhook secret end up in the functions’ environment, which Lambda encrypts at rest. Anyone who may read a function’s configuration can read them; restrict that permission as you would restrict the secrets themselves.
The cost model
Prices used
USD, on demand, us-east-1, as assumed on 2026-11-15, without any free allowance. Each name links to the official price list.
| Service | Unit | Price |
|---|---|---|
| AWS Lambda, arm64 | Per GB-second; per million requests | 0.0000133334; 0.20 |
| Amazon SQS, standard | Per million requests (each 64 KB of a message is one) | 0.40 |
| Amazon S3, Standard | Per GB-month; per million writes or lists; per million reads | 0.023; 5.00; 0.40 |
| Amazon CloudFront | Per million HTTPS requests; per GB sent to the function; per GB sent out | 1.00; 0.02; 0.085 |
| Data leaving AWS from S3 | Per GB | 0.09 |
| Amazon RDS for PostgreSQL | db.t4g.micro per hour; db.t4g.medium per hour; disk per GB-month; a public address per hour | 0.016; 0.065; 0.115; 0.005 |
| Amazon EventBridge Scheduler | Per million invocations | 1.00 |
| Amazon CloudWatch | Logs per GB; per alarm a month | 0.50; 0.10 |
| AWS Systems Manager Parameter Store | A standard parameter, SecureString included | 0.00 |
| Amazon SES Cloud | Per 1,000 e-mails | 0.10 |
| NAT gateway (not in the reference) | Per hour; per GB | 0.045; 0.045 |
AWS gives every account a monthly allowance that covers a small deployment’s functions (400,000 GB-seconds and a million requests), its queue (a million requests) and its address (10 million requests). The unit costs below ignore it, so they stay true at any size.
An idle deployment
Nothing arrives. What still costs:
| Line | Arithmetic | A month |
|---|---|---|
| The minute tick | 43,200 calls × 1 s × 1 GB × 0.0000133334, plus 43,200 × 0.20 ÷ 1,000,000 | 0.59 |
| The schedule | 43,200 × 1.00 ÷ 1,000,000 | 0.04 |
| The queue’s empty polls | About 15 a minute: 648,000 × 0.40 ÷ 1,000,000 | 0.26 |
| Three alarms | 3 × 0.10 | 0.30 |
| Two SecureStrings | Standard parameters | 0.00 |
| Logs | About 0.1 GB | 0.05 |
| Bucket, address, the other two functions | Nothing arrives, nothing is billed | 0.00 |
| The engine, idle | ≈ 1.24 | |
Postgres, the sypnia-db stack | 0.016 × 730 + 20 × 0.115 | 13.98 |
| Its public address | 0.005 × 730 | 3.65 |
| Total, idle | ≈ 18.87 |
With a Postgres you already have, an idle engine is under USD 2 a month, and with the free allowance it is cents.
Unit costs
Receiving, storing and processing events. The unit that costs is not the event: it is the batch, and the segment it lands in.
| Step, per 1,000 batches | Service | Arithmetic | USD |
|---|---|---|---|
| The address receives them | CloudFront | 1,000 × 1.00 ÷ 1,000,000 | 0.00100 |
| The bodies reach the function, 3 KB each | CloudFront | 0.003 GB × 0.02 | 0.00006 |
sypnia-ingest is called | Lambda | 1,000 × 0.20 ÷ 1,000,000 | 0.00020 |
| It runs 50 ms at 256 MB | Lambda | 12.5 GB-s × 0.0000133334 | 0.00017 |
| The batches are sent to the queue | SQS | 1,000 × 0.40 ÷ 1,000,000 | 0.00040 |
| The worker receives and deletes them, in groups | SQS | About 670 requests × 0.40 ÷ 1,000,000 | 0.00027 |
| Receiving | 0.0021 | ||
| Segments written: at most one per batch | S3 | 1,000 × 5.00 ÷ 1,000,000 | 0.00500 |
| Each read once by the fast path and up to 11 times by the roll-up | S3 | 12,000 × 0.40 ÷ 1,000,000 | 0.00480 |
| The worker’s time for them, 20 ms each at 1 GB | Lambda | 20 GB-s × 0.0000133334 | 0.00027 |
| Storing and processing, at most | 0.0101 | ||
| Total, at most | 0.0122 |
Segments are the larger half, and they are capped: a project and environment gets at most one segment per 10-second delivery, 259,200 a month, however much it sends. So the cost of a million events depends on how they arrive:
| A million events | Batches | Segments | Arithmetic | USD |
|---|---|---|---|---|
| A busy project: the small project of Deployment shapes, 4 million events a month | 225,000 | 65,000 (the cap, shared by 4 million) | 225 × 0.0021 + 65 × 0.0101 + 15,000 session files × 5 ÷ 1,000,000 | ≈ 1.20 |
| A quiet project: every batch alone in its 10 seconds | 225,000 | 225,000 | 225 × 0.0122 + 0.08 | ≈ 2.80 |
| The worst shape: every event alone in a batch, two events a session | 1,000,000 | 1,000,000 | 1,000 × 0.0122 + 1,000,000 session files × 5 ÷ 1,000,000 | ≈ 17.20 |
Measured on the system this engine comes from: 4.4 events a batch and 30 batches a session, which is where 225,000 comes from. The worst shape is what a hard limit must assume, and what nobody’s app looks like.
Storing. USD 0.023 per GB-month. A GB is about 8 million events as segments (125 MB a million), or 2.7 million with their per-session files and Parquet (375 MB a million), or about 1,330 short replays.
Replays. A recording is one object per 10 seconds, sent through the address and sypnia-ingest, and read by the browser straight from S3 when someone watches it.
| Per 1,000 replays | A short one: 22 chunks, 0.75 MB (measured there) | The longest: 720 chunks, 144 MB, two hours |
|---|---|---|
| Requests through the address and the function | 22,000 × (1.00 + 0.20 + 0.33) ÷ 1,000,000 = 0.034 | 1.10 |
| Bodies to the function | 0.75 GB × 0.02 = 0.015 | 2.88 |
| Objects written | 22,000 × 5 ÷ 1,000,000 = 0.110 | 3.60 |
| Stored | ≈ 0.16 | ≈ 7.58 |
| Kept, per month of retention | 0.75 GB × 0.023 = 0.017 | 3.31 |
| Watched once, each of them | 22,000 reads × 0.40 ÷ 1,000,000 + 0.75 GB × 0.09 = 0.076 | ≈ 13.25 |
A short replay costs two hundredths of a cent to store and watch. The longest costs two cents, almost 90 times more, and most of that is the data leaving AWS when it is watched.
An AI analysis. The engine counts tokens, not money; the price is your provider’s. The formula:
cost = calls × (tokens_in × price_in + tokens_out × price_out) ÷ 1,000,000| Tokens in | Tokens out | Calls | |
|---|---|---|---|
| A usual analysis | 8,000: about 24,000 characters of context at 3 to 4 characters a token, plus the fixed instructions | 700 | 1.15: assumed, one answer in seven fails the check and is asked again |
| The largest the engine allows | 9,000 | 2,000 (ai.max_output_tokens) | 3 |
| Price of the model, per million tokens in / out | A usual analysis | The largest |
|---|---|---|
| 0.15 / 0.60 | 0.0019 | 0.0077 |
| 0.40 / 1.60 | 0.0050 | 0.0204 |
| 3.00 / 15.00 | 0.040 | 0.171 |
So an analysis costs between a fifth of a cent and four cents, depending on the model, and up to 17 cents in the worst case with an expensive one. Measured on the system this engine comes from: USD 0.08 to 0.20 for a weekly run of 15 to 25 calls, about half a cent to a cent a call. No model is named here because none is promised.
An uptime check. One request a minute, made inside the pass that runs anyway: about USD 0.02 a month for its 43,200 result rows and its share of the worker’s time.
Two self-hosted examples
The two projects of Deployment shapes, summed by service. The line-by-line arithmetic is there; the last rows add two small fixed items that table leaves out.
| USD a month | Small: 4 million events, 30,000 sessions | Medium: 40 million events, 300,000 sessions |
|---|---|---|
| Lambda | 3.31 | 15.26 |
| SQS | 0.60 | 4.00 |
| S3: writes, reads, storage | 3.52 | 14.34 |
| CloudWatch logs | 0.50 | 2.00 |
| CloudFront | 0.00 (inside the allowance) | 0.00 |
| The engine | ≈ 8 | ≈ 36 |
| RDS for PostgreSQL | ≈ 14 (db.t4g.micro) | 25 to 50 (2 to 4 GB of memory) |
| Total, as on the other pages | ≈ 22 | ≈ 60 to 85 |
| Three alarms, the database’s public address | 0.30 + 3.65 = 3.95 | 3.95 |
| Everything on the bill | ≈ 26 | ≈ 64 to 89 |
| With the functions in a private network instead | + 32.85 for the NAT gateway, − 3.65 | The same |
Not included: the model, at your provider’s price (a project that makes 200 usual analyses a month at 0.40 / 1.60 pays USD 1.00), and data leaving AWS when you watch replays (0.09 per GB).
One small project, at its usage
What one small project adds to the bill of a deployment that is already running, line by line, from the unit costs above. The project, a month: up to 20,000 events received (5,000 of them errors, traces and samples, the rest free events), 50 replays of at most 30 minutes kept 7 days, one uptime check and 50 analyses. The deployment itself, its idle cost and its database, is not in it.
At the worst shape, every event alone in a batch, every replay at its longest and watched once, every analysis the largest the engine allows:
| Line | Usage | Unit cost, worst shape | USD a month |
|---|---|---|---|
| Events received | 20,000 batches of one event | 0.0122 per 1,000 batches | 0.24 |
| …their sessions | 10,000 sessions, two files written each | 5.00 per million writes | 0.10 |
| …their roll-ups | A run in every 5 minutes of the month: 8,640 × 0.3 GB-s | 0.0000133334 per GB-s | 0.04 |
| Replays | 50 × 180 chunks, 36 MB each, kept 7 days; every one watched once | 0.0021 to store + 0.0033 to watch | 0.27 |
| Uptime check | 43,200 checks | 0.02 | |
| Analyses, model at 0.40 / 1.60 | 50 of the largest | 0.0204 | 1.02 |
| Total | ≈ 1.69 |
The same project with the shape real apps have (4.4 events a batch, short replays of which one in five is watched, usual analyses) adds about USD 0.31: analyses 0.25, events 0.03, the uptime check 0.02, replays 0.01.
Read this diagram as text
Two stacked bars on an axis from USD 0 to 2 a month. One small project at the worst shape adds USD 1.69: AI analyses 1.02, events (receive, store, process) 0.38, replays (store and watch) 0.27, uptime check 0.02. The same project with the shape real apps have adds USD 0.31: AI analyses 0.25, events 0.03, uptime check 0.02, replays 0.01.
Two things to read from it:
- The model is the bill. Storage, events and replays together are under half of the worst case and under a fifth of the real one. With a model at 3.00 / 15.00, the same 50 analyses cost up to USD 8.55; the engine’s default is 100 a day for each project, so
SYPNIA_AI_MAX_ANALYSES_PER_DAYis the first number to set. See Limits. - Long recordings that are all watched are the next line. At two hours, 50 replays cost 50 × (7.58 + 13.25) ÷ 1,000 = 1.04 to store and watch once, plus 0.17 for each month they are kept. Most of it is the data leaving AWS when they are watched.
A self-hosted engine sends alerts by webhook, so there is no e-mail line.
What changed from the system this comes from
| There | Here | Why |
|---|---|---|
| An ingest function, an hourly one, a daily one and a weekly one, in TypeScript, with a native query engine as a 68 MB binding | Three functions by role, one Rust binary, no native dependency | One program to read, arm64, 300 ms cold starts |
| A managed delivery stream between ingest and the bucket | SQS, with a dead-letter queue and a redrive command | Freshness; objects named by project; failures you can see |
| The app’s shared database, with one role for everything | A database and a role of the engine’s own, on an instance in a stack of its own | The shared one ran out of memory once. Separate databases and roles keep each application to its own data; the instance is resized, not migrated, when it runs short |
| Retention as bucket lifecycle rules and a database cron extension | The engine’s daily job | The same on any store and any Postgres |
| Cost estimated once, for one app | A unit cost per batch, replay and analysis | Any deployment can be priced from its traffic before it runs |
Next
-
What happens when something fails
Every hop of this deployment with its retries, its dead-letter exit and its replay command. - The template, step by step, on your own account.
- What makes a self-hosted bill move, and the first limits you meet.