How to run KafScale on Cloudflare R2
Run Kafka yourself and keep the data on Cloudflare R2. R2’s free tier gives you 10 GB-month of storage every month, and R2 charges nothing for egress for any storage class (source: Cloudflare R2 pricing). KafScale brokers are stateless and keep every record in object storage, so R2 is the whole storage bill. Consumers in another cloud, region or office read segments from R2 without transfer fees.
Stream your backend data straight to the apps you run on Cloudflare
KafScale can feed the apps you already run on Cloudflare. The records live in R2, and a small consumer you run is the link: it reads a topic and writes an index, the latest state or embeddings to R2, Workers KV or Vectorize. A Worker or a Pages app then serves that data at the edge. Workers cannot speak the Kafka protocol directly, so they cannot consume from the KafScale proxy themselves.
Web3 indexing
Chain events, for example XRPL transactions or EVM logs, are produced into a KafScale topic. A small consumer builds an index or the latest state and writes it to R2 or Workers KV. A dApp front end on Workers or Pages reads that index at the edge. If you change the index shape, replay the topic from R2 and rebuild it. Those reads have no egress cost (source: Cloudflare R2 pricing).
- Your chain indexer, or another process you run, produces events into a KafScale topic. The records stay in R2.
- A consumer you run reads the topic and writes an index or the latest state to R2 or Workers KV.
- A dApp on Workers or Pages serves that index at the edge.
- To rebuild, replay the topic from R2. There is no egress fee for those reads.
AI and RAG
Documents, tickets or events stream through KafScale. A consumer you run chunks the records, embeds them with Workers AI and stores the vectors in Vectorize. A Worker then serves search or chat over that data (see Cloudflare’s RAG tutorial). The full history stays in R2, so when you change embedding models you can re-embed from the topic without paying egress (source: Cloudflare R2 pricing).
- Documents, tickets or events are produced into a KafScale topic and stored in R2.
- A consumer you run chunks each record, embeds it with Workers AI and writes the vectors to Vectorize.
- A Worker serves search or chat over the index.
- When you change models, replay the topic from R2 and re-embed.
Cloudflare R2
Cloudflare R2 is S3-compatible object storage. KafScale talks to it with the same AWS SDK it uses for Amazon S3, so you don’t need a plugin or a separate driver. You set the R2 endpoint, region auto and an API token.
Why it fits KafScale:
- No egress fees. Kafka is read-heavy: every consumer group reads every record. On R2 those reads cost Class B operations, not bandwidth.
- Conditional writes. Brokers write every segment with
If-None-Match: *, so a broker that lost its partition lease can’t overwrite the new owner’s data. R2 returns412 Precondition Failedexactly like S3. KafScale checks this at startup, and the check passed on R2. - Small clusters cost nothing. A dev or demo cluster fits in the free tier if you watch the write count. See Free tier and write count.
Before you start
- A Cloudflare account with R2 turned on. R2 asks for a payment method even for the free tier.
- A Kubernetes cluster with Helm 3, and
kubectlaccess. - KafScale v2.2.0 or later.
Every step below is copy and paste. Replace <ACCOUNT_ID>, the bucket name and the keys with your own. Keys always go in files and Secrets, never on a command line.
1. Create an R2 bucket and an API token
- In the Cloudflare dashboard, open R2 Object Storage and select Create bucket. Pick a name, for example
kafscale-data. Leave the storage class on Standard: the free tier does not apply to Infrequent Access. - Open Manage API tokens in R2 and create a token with Object Read & Write. Scope it to that one bucket. See R2 API tokens.
- Note the Access Key ID, the Secret Access Key and the S3 endpoint
https://<ACCOUNT_ID>.r2.cloudflarestorage.com. Cloudflare shows the secret only once.
KafScale only needs object access to this bucket. Brokers check that the bucket exists at startup and never need to create it.
2. Store the R2 keys in a Kubernetes Secret
Put the keys in a file that only you can read, then create the Secret from it. This keeps them out of your shell history and out of Helm values.
kubectl create namespace kafscale
umask 077
cat > r2.env <<'ENV'
AWS_ACCESS_KEY_ID=<access key id>
AWS_SECRET_ACCESS_KEY=<secret access key>
ENV
kubectl -n kafscale create secret generic kafscale-s3 --from-env-file=r2.env
rm r2.env
Brokers, the LFS proxy and the etcd snapshot jobs load this Secret as environment variables.
3. Install KafScale with Helm and point the cluster at R2
Install the operator and the proxy. Save this as values-r2.yaml. An empty etcdEndpoints lets the operator run etcd for you:
operator:
etcdEndpoints: [""]
etcdReplicas: 3
proxy:
enabled: true
replicaCount: 2
etcdEndpoints:
- http://kafscale-etcd-client.kafscale.svc.cluster.local:2379
advertisedHost: kafka.example.com
advertisedPort: 9092
git clone --branch v2.2.0 --depth 1 https://github.com/KafScale/platform.git kafscale
helm upgrade --install kafscale kafscale/deploy/helm/kafscale \
-n kafscale -f values-r2.yaml
The chart’s appVersion is v2.2.0, so the operator, brokers and proxies run the ghcr.io/kafscale/kafscale-*:v2.2.0 images. The Iceberg processor chart in step 6 uses the same tag.
Then create the cluster. Save this as cluster-r2.yaml. The R2 part is the s3 block:
apiVersion: kafscale.io/v1
kind: KafscaleCluster
metadata:
name: kafscale
namespace: kafscale
spec:
brokers:
replicas: 2
s3:
bucket: kafscale-data
region: auto
endpoint: https://<ACCOUNT_ID>.r2.cloudflarestorage.com
credentialsSecretRef: kafscale-s3
etcd:
endpoints: []
kubectl apply -f cluster-r2.yaml
kubectl -n kafscale get kafscalecluster kafscale \
-o jsonpath='{range .status.conditions[*]}{.type}={.status} {.reason}{"\n"}{end}'
S3Credentials=True SecretKeysFound
EtcdSnapshotAccess=True SnapshotAccessOK
EtcdSnapshot=False SnapshotNeverSucceeded
EtcdMaintenance=True MaintenanceScheduled
EtcdAvailable=True EtcdReady
Ready=True Ready
S3Credentials=True and Ready=True mean the brokers started. EtcdSnapshot turns True after the first snapshot, see step 4. A broker only starts listening after its conditional write check against R2 succeeds.
Settings R2 needs
| Setting | Value for R2 | Notes |
|---|---|---|
spec.s3.endpoint |
https://<ACCOUNT_ID>.r2.cloudflarestorage.com |
For an EU jurisdiction bucket, use the EU endpoint Cloudflare shows for the bucket. |
spec.s3.region |
auto |
R2 ignores the region, but the AWS SDK needs one. |
| Path-style addressing | On | The operator sets KAFSCALE_S3_PATH_STYLE=true whenever endpoint is set. Nothing to configure. |
spec.s3.bucket |
Your bucket | Must exist. |
spec.s3.credentialsSecretRef |
kafscale-s3 |
Keys AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. |
| AWS SDK checksums | Default | R2 accepts the SDK’s default CRC32 checksums. See Checksums. |
Running the broker outside Kubernetes uses the same values as environment variables: KAFSCALE_S3_ENDPOINT, KAFSCALE_S3_REGION=auto, KAFSCALE_S3_BUCKET and KAFSCALE_S3_PATH_STYLE=true.
4. Keep etcd snapshots in the same bucket
With operator-managed etcd, the operator backs up etcd every hour. By default the snapshots go to the cluster’s own bucket, spec.s3.bucket, under _kafscale/etcd-snapshots/<namespace>/<cluster>/. The snapshot jobs reuse spec.s3.endpoint and the kafscale-s3 Secret, so the bucket-scoped token from step 1 is all they need. For the cluster above, that’s _kafscale/etcd-snapshots/kafscale/kafscale/ in kafscale-data.
Only change this if you want the snapshots somewhere else. The chart has values for it:
operator:
etcdSnapshot:
prefix: backups/etcd
prefixis a base prefix. The operator always adds<namespace>/<cluster>, so the example writes tobackups/etcd/kafscale/kafscale/.bucketsets a separate snapshot bucket. The token then needs access to that bucket too. LeavecreateBucketoff unless the token is allowed to create buckets.protectBuckethas no effect on R2. R2 doesn’t implement bucket versioning or the public access block, so the snapshot job logs that and continues.
Run a snapshot once to check:
kubectl -n kafscale create job snap-check --from=cronjob/kafscale-etcd-snapshot
kubectl -n kafscale logs job/snap-check --all-containers | tail -3
aws s3 ls s3://kafscale-data/_kafscale/etcd-snapshots/kafscale/kafscale/ \
--endpoint-url https://<ACCOUNT_ID>.r2.cloudflarestorage.com
The job log ends with the two uploads, and the listing shows the snapshot and its checksum:
upload: ../snapshots/etcd-snapshot.db to s3://kafscale-data/_kafscale/etcd-snapshots/kafscale/kafscale/20261202200810.db
upload: ../snapshots/etcd-snapshot.db.sha256 to s3://kafscale-data/_kafscale/etcd-snapshots/kafscale/kafscale/20261202200810.db.sha256
2026-12-02 21:08:11 94 20261202200810.db.sha256
2026-12-02 21:08:11 24608 20261202200810.db
After that, the cluster reports EtcdSnapshot=True SnapshotHealthy.
The aws commands in this guide read your R2 keys from a profile or from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Set AWS_DEFAULT_REGION=auto too. Load them from a file only you can read. Don’t type them on the command line.
5. Produce, consume and check the bucket
Create the topic and produce six JSON orders, one key:value per line. Step 6 turns them into an Iceberg table, so every value is a JSON object with the mapped columns:
export BOOTSTRAP=kafka.example.com:9092
kafka-topics.sh --bootstrap-server $BOOTSTRAP --create --topic orders --partitions 4 --replication-factor 1
cat > orders.jsonl <<'EOF'
1:{"order_id":1,"status":"paid","amount":19.99,"region":"eu"}
2:{"order_id":2,"status":"paid","amount":5.50,"region":"us"}
3:{"order_id":3,"status":"shipped","amount":42.00,"region":"eu"}
4:{"order_id":4,"status":"paid","amount":12.25,"region":"apac"}
5:{"order_id":5,"status":"cancelled","amount":7.00,"region":"us"}
6:{"order_id":6,"status":"shipped","amount":30.10,"region":"eu"}
EOF
kcat -b $BOOTSTRAP -P -t orders -K: -X acks=all < orders.jsonl
kcat -b $BOOTSTRAP -C -t orders -o beginning -e -q -f '%k:%s\n'
4:{"order_id":4,"status":"paid","amount":12.25,"region":"apac"}
6:{"order_id":6,"status":"shipped","amount":30.10,"region":"eu"}
2:{"order_id":2,"status":"paid","amount":5.50,"region":"us"}
5:{"order_id":5,"status":"cancelled","amount":7.00,"region":"us"}
1:{"order_id":1,"status":"paid","amount":19.99,"region":"eu"}
3:{"order_id":3,"status":"shipped","amount":42.00,"region":"eu"}
The consumer reads partition by partition, so the order differs from the file.
--partitions and --replication-factor are optional. Without them the topic gets KAFSCALE_AUTO_CREATE_PARTITIONS partitions (1 if unset or not positive) and replication factor 1.
The segments show up in R2 under <namespace>/<topic>/<partition>/:
aws s3 ls s3://kafscale-data/kafscale/orders/ --recursive \
--endpoint-url https://<ACCOUNT_ID>.r2.cloudflarestorage.com
2026-12-02 21:16:10 68 kafscale/orders/0/segment-00000000000000000000.index
2026-12-02 21:16:10 250 kafscale/orders/0/segment-00000000000000000000.kfs
2026-12-02 21:16:11 68 kafscale/orders/1/segment-00000000000000000000.index
2026-12-02 21:16:11 176 kafscale/orders/1/segment-00000000000000000000.kfs
2026-12-02 21:16:11 68 kafscale/orders/2/segment-00000000000000000000.index
2026-12-02 21:16:11 181 kafscale/orders/2/segment-00000000000000000000.kfs
2026-12-02 21:16:10 68 kafscale/orders/3/segment-00000000000000000000.index
2026-12-02 21:16:09 248 kafscale/orders/3/segment-00000000000000000000.kfs
Each flush writes one .kfs segment and its .index.
For other tools, see How to work with Kafka tools and KafScale.
6. Write topics to Iceberg tables in R2 Data Catalog
The KafScale Iceberg processor reads segments from the bucket and writes Iceberg tables into R2 Data Catalog (now called Basin Catalog), the Iceberg REST catalog built into the bucket. DuckDB, Spark, Trino or any other Iceberg engine can then query the tables.
-
Turn on the catalog for the bucket and note the Warehouse and Catalog URI it prints:
npx wrangler basin catalog enable kafscale-dataThe warehouse is
<ACCOUNT_ID>_kafscale-dataand the URI ishttps://catalog.cloudflarestorage.com/<ACCOUNT_ID>/kafscale-data. -
Create an R2 API token with Admin Read & Write for the processor only, and note its Token value. Store it in its own Secret:
umask 077 read -rs -p "Catalog token: " TOKEN; echo printf '%s' "$TOKEN" > r2-catalog-token unset TOKEN kubectl -n kafscale create secret generic r2-catalog --from-file=token=r2-catalog-token rm r2-catalog-token -
Install the processor with a values file,
iceberg-r2.yaml:replicaCount: 2 s3: credentialsSecretRef: kafscale-s3 catalogToken: secretName: r2-catalog secretKey: token config: s3: bucket: kafscale-data namespace: kafscale endpoint: https://<ACCOUNT_ID>.r2.cloudflarestorage.com region: auto iceberg: catalog: type: rest uri: https://catalog.cloudflarestorage.com/<ACCOUNT_ID>/kafscale-data manages_locations: true warehouse: <ACCOUNT_ID>_kafscale-data etcd: endpoints: - http://kafscale-etcd-client.kafscale.svc.cluster.local:2379 mappings: - topic: orders table: kafscale.orders mode: append create_table_if_missing: true schema: columns: - {name: order_id, type: long, required: true} - {name: status, type: string} - {name: amount, type: double} - {name: region, type: string}helm upgrade --install iceberg-processor \ kafscale/addons/processors/iceberg-processor/deploy/helm/iceberg-processor \ -n kafscale -f iceberg-r2.yaml
What the R2 settings do:
iceberg.catalog.manages_locations: trueis required on R2. The processor then creates tables without a location and never setswrite.data.pathorwrite.metadata.path. R2 picks the location under__r2_data_catalog/and rejects both settings otherwise.iceberg.warehouseis the warehouse name, not an S3 path.catalogToken.secretNameandcatalogToken.secretKeyload the token intoKAFSCALE_ICEBERG_CATALOG_TOKEN, which wins overiceberg.catalog.token. Leaveiceberg.catalog.tokenempty so the token stays out of the ConfigMap.s3.credentialsSecretRefgives the processor the bucket keys from step 2 to read segments. For the table files, the catalog hands out S3 credentials with each table, so the processor needs no other keys.schema.registry.base_urlis empty by default. This guide lists thecolumns, so it needs no schema registry. A mapping withoutcolumnsneeds one.- Topics without a mapping are skipped with one log line.
- Replicas share the partitions through leases. When two replicas commit to the same table at once, R2 answers with HTTP 409. The processor reloads the table and retries up to 5 times, then retries the batch from the committed offset on the next poll. Every row carries a
record_idof<topic>:<partition>:<offset>. - The chart restarts the pods when you change
configor rotate a Secret it uses. - Don’t put a lifecycle or lock rule on
__r2_data_catalog/. The catalog manages those files.
Query the table with DuckDB and a read-only token (Admin Read only) in R2_CATALOG_TOKEN:
INSTALL iceberg; LOAD iceberg;
CREATE SECRET r2 (TYPE iceberg, TOKEN getenv('R2_CATALOG_TOKEN'));
ATTACH '<ACCOUNT_ID>_kafscale-data' AS lake (TYPE iceberg, URI 'https://catalog.cloudflarestorage.com/<ACCOUNT_ID>/kafscale-data', SECRET r2);
SELECT status, count(*) AS orders, round(sum(amount), 2) AS total FROM lake.kafscale.orders GROUP BY ALL;
┌───────────┬────────┬────────┐
│ status │ orders │ total │
│ varchar │ int64 │ double │
├───────────┼────────┼────────┤
│ paid │ 3 │ 37.74 │
│ cancelled │ 1 │ 7.0 │
│ shipped │ 2 │ 72.1 │
└───────────┴────────┴────────┘
Keep values that are not JSON, or that miss a required column, out of a mapped topic. Such a record is still written, with empty columns, and a required long column shows 0 (see issue #492).
DuckDB needs no S3 keys. It reads the table files with the credentials the catalog hands out.
Credentials and immutable data
Which token each part needs
R2 has four token permissions (R2 API tokens):
| Permission | Allows |
|---|---|
| Admin Read & Write | Create and delete buckets, edit bucket settings including lock rules, read and write objects and the data catalog |
| Admin Read only | Read bucket settings, objects and the data catalog |
| Object Read & Write | Read, write, list, overwrite and delete objects in the buckets you pick |
| Object Read only | Read and list objects in the buckets you pick |
No long-lived token can write without also being able to overwrite and delete. To make data immutable, use bucket locks.
- Brokers, the LFS proxy and the etcd snapshot jobs: Object Read & Write, scoped to the KafScale bucket, as in step 1.
- Iceberg processor writing to R2 Data Catalog (now Basin Catalog): its own Admin Read & Write token in its own Secret, as in step 6. Cloudflare’s catalog guide needs it to create tables and commit. The catalog hands out S3 credentials for the table files based on this token, so treat it like a key to the whole bucket. Brokers and readers never get it.
- Readers such as DuckDB or a dashboard: read-only catalog access plus object read on the bucket. That’s Admin Read only in the dashboard, or Workers R2 Data Catalog Read with Workers R2 Storage Bucket Item Read when you create the token through the API.
Anyone holding an Admin Read & Write token can remove a lock rule. Never give one to brokers or readers, and give the Iceberg processor its own token. Keep every token in a Kubernetes Secret created from a file, as in step 2, and never put one on a command line or in helm --set.
Stricter: temporary credentials without delete
R2 can derive temporary credentials from a parent token. When you sign them yourself, you can pass an actions list and leave out DeleteObject and DeleteObjects. Brokers need GetObject, HeadObject, ListObjectsV2 and PutObject. Add the multipart actions if you run the LFS proxy.
Put the three values in the Secret from step 2 as AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN, the same names AWS and MinIO use. The credentials expire, so a job has to sign new ones and update the Secret before they do. That job holds the parent token, so run it apart from the KafScale pods. When the Secret changes, the operator rolls the brokers and the LFS proxy onto the new values.
Before you rely on it:
- These credentials can still overwrite objects. Use them together with bucket locks.
- Brokers log a warning when they can’t remove their startup probe object from
__health/, and the LFS proxy can’t clean up failed uploads.kafscale-cli pruneneeds other credentials. - The schema registry and the console from the Helm chart read
AWS_SESSION_TOKENfrom their Secret, so they can use temporary credentials. The schema registry reads the keys again every minute, so it needs no restart when you rotate them. - Brokers call
HeadBucketat startup, and that isn’t in Cloudflare’s actions list. This setup wasn’t part of the test run below, so restart a broker once to check it.
Make topic data immutable with bucket locks
R2 bucket locks block overwrite and delete for objects under a prefix, for a set time or forever. New objects can still be written. A blocked request gets 409 ObjectLockedByBucketPolicy, even when it also carries If-None-Match.
This fits how KafScale writes. Brokers never delete segments, retention runs through lifecycle rules (see Retention and cleanup), every segment is written with If-None-Match: *, and its index is written once right after it.
-
Lock each topic you want immutable. Segments live under
<namespace>/<topic>/, which iskafscale/ordersin this guide:npx wrangler r2 bucket lock add kafscale-data lock-orders kafscale/orders --retention-days 30The prefix is a plain string match. It also covers
kafscale/orders@1/, where a recreatedorderstopic writes, and any topic whose name starts withorders, such asorders-dlq. -
Lock only the timestamped etcd snapshot files. They’re named by UTC time, like
20261201140000.db, so lock_kafscale/etcd-snapshots/<namespace>/<cluster>/2. -
Add an object lifecycle rule on each locked prefix that expires objects no earlier than the lock does. A lock beats a lifecycle rule, so nothing goes before the lock ends. Add a 1 day expiry on
__health/and on_kafscale/etcd-snapshots/<namespace>/<cluster>/health/for probe objects that couldn’t be removed. If a bucket policy denies deletes, setoperator.s3Probe.skipDeletetotrueand the operator skips the delete.
While a lock holds, kafscale-cli prune fails on that prefix.
Don’t lock these:
| Prefix | Why |
|---|---|
The whole bucket, or __health/ |
Each broker writes a probe object twice at startup and expects 412 on the second write. A lock answers 409, so the broker exits and keeps restarting. |
All of kafscale/ |
It also covers the schema registry (kafscale/@schemas/) and large file storage (kafscale/@lfs/), which replace and delete objects. |
_kafscale/etcd-snapshots/<namespace>/<cluster>/health/ |
The operator’s snapshot access check writes there. |
__r2_data_catalog/ |
Catalog compaction rewrites and removes files there. |
What was tested
Steps 2 to 6 above, with their output, were run on 2026-12-02 with the released v2.2.0 images and the Helm chart from the v2.2.0 tag: kind (kubeProxyMode: nftables), 2 brokers, 2 proxy replicas, 3 operator-managed etcd pods, one R2 bucket, Apache Kafka CLI 4.3.1, kcat 1.7.1 and DuckDB 2.0.1. The bucket was emptied afterwards.
The release QA runs for v2.2.0 on main (commits 40c3533 and 5a1f3da), on 2026-12-01: images and Helm charts built from main, kind (kubeProxyMode: nftables), 2 brokers, 2 proxy replicas, operator-managed etcd, one R2 bucket.
| Check | Result |
|---|---|
Broker startup conditional write check (If-None-Match: * twice, second write must get 412) |
Passed on R2, both brokers started |
1,000 keyed records with the Kafka console producer (acks=all), read back with kcat, partitions on both brokers |
SHA-256 of the sorted key and value lines matched after the round trip |
LogStartOffset in Produce and Fetch responses |
Matches the earliest offset |
Topic config changes with kafka-configs.sh, including 100 rounds of concurrent changes from clients on both brokers |
No failed or lost updates |
etcd snapshot to _kafscale/etcd-snapshots/kafscale/kafscale/ with protectBucket: true |
Uploaded. Versioning stayed off and the public access block was skipped |
| Snapshot access probe | Written and removed, no health objects left behind |
| Restore after deleting the etcd pod | Group offsets, topic configs and data checksums unchanged |
| Cluster pointed at a missing bucket | Operator reports NoSuchBucket, no broker starts, no bucket is created |
| Topic delete and recreate | The new topic writes under cli-events@1/, no key collisions |
| Broker errors in the logs | None |
Iceberg processor, 3 replicas, manages_locations: true, 12,000 records on 4 partitions and 1,000 on 2 partitions |
12,000 and 1,000 rows in R2 Data Catalog. No lost or duplicated record IDs, and the order amounts add up to the input. Queried with DuckDB |
| 3 replicas committing to one table at once | R2 answered with 409 conflicts. 15 commits went through on a retry and 9 batches were retried on the next poll |
| Table files read with the catalog’s credentials | DuckDB read every row with only the catalog token, no S3 keys |
Checksums
Current AWS SDKs add a CRC32 checksum to every upload by default (aws-chunked encoding with an x-amz-checksum-crc32 trailer) and ask for checksums on downloads. Some S3-compatible stores reject that. R2 accepts it: the conditional puts, plain puts, gets and range gets all worked with the SDK defaults, so you don’t need to change anything.
If a proxy or gateway in front of R2 rejects the checksum headers, the AWS SDK reads two environment variables. Add them to the same Secret so brokers pick them up:
AWS_REQUEST_CHECKSUM_CALCULATION=when_required
AWS_RESPONSE_CHECKSUM_VALIDATION=when_required
Latency
With the default KAFSCALE_PRODUCE_SYNC_FLUSH=true, a produce with acks=1 or acks=all returns after its data is in R2. Latency then depends on how far the brokers are from the bucket. In a test on 2026-11-30, the cluster ran outside the bucket’s region:
- One record with
acks=all: about 290 to 420 ms (6 runs). kafka-producer-perf-testat 10 records per second, 200 byte records, 2 partitions,acks=all: p50 1,760 ms, p99 2,093 ms. Each partition flushes one request at a time, so separate small requests queue behind each other.
Run the brokers close to the bucket’s location, and batch on the producer (linger.ms, batch.size) so one flush carries many records. See Latency and batching.
Known limits
Free tier and write count
From the R2 pricing page, the free tier each month is:
| Free per month | |
|---|---|
| Storage (Standard) | 10 GB-month |
| Class A operations | 1 million requests |
| Class B operations | 10 million requests |
| Egress | Free |
Above that, Standard storage costs $0.015 per GB-month, Class A $4.50 per million and Class B $0.36 per million. DeleteObject is free.
Class A includes PutObject and ListObjects, and a PutObject that gets 412 Precondition Failed still counts. For KafScale that means:
- Every flush writes a segment and an index object, so 2 Class A operations per partition per flush.
- With sync flush, a producer that sends one request per second to one partition makes about 2 × 86,400 × 30 = 5.2 million writes a month. That’s well over the free 1 million.
- Batch on the producer, or use fewer, busier partitions.
KAFSCALE_PRODUCE_SYNC_FLUSH=falsewith a longerKAFSCALE_FLUSH_INTERVAL_MScuts writes further, but records acknowledged since the last flush are lost if a broker stops. See the produce flush policy in Operations. - Partition restore after a broker restart lists objects, which is Class A on R2.
Retention and cleanup
- KafScale doesn’t delete segments when
retention.mspasses. Age-based cleanup is a bucket rule, the same as on S3. R2 has object lifecycle rules. Scope them to topic prefixes and don’t let them remove segments that consumers still need. - Deleting a topic keeps its data.
kafscale-cli pruneremoves it.
Not available on R2
- Bucket versioning and public access block settings return
NotImplemented. The snapshot job skips them, sooperator.etcdSnapshot.protectBuckethas no effect on R2. - KMS server-side encryption is an AWS feature. R2 encrypts objects at rest itself, so leave
spec.s3.kmsKeyArnunset.
Related
- Supported storage: every S3-compatible backend and what it needs
- Connect your S3
- Operations: flush policy, etcd snapshots,
kafscale-cli prune - How to work with Kafka tools and KafScale