<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohammad R. Rashid</title>
    <description>The latest articles on DEV Community by Mohammad R. Rashid (@mohammadrrashid).</description>
    <link>https://dev.to/mohammadrrashid</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3895123%2Fbff8cd9e-37f5-45ce-a675-748158084978.jpeg</url>
      <title>DEV Community: Mohammad R. Rashid</title>
      <link>https://dev.to/mohammadrrashid</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohammadrrashid"/>
    <language>en</language>
    <item>
      <title>How We Keep Mobile Session Replay 17x Cheaper Than PostHog</title>
      <dc:creator>Mohammad R. Rashid</dc:creator>
      <pubDate>Mon, 18 May 2026 03:25:40 +0000</pubDate>
      <link>https://dev.to/mohammadrrashid/how-we-keep-mobile-session-replay-17x-cheaper-than-posthog-d5k</link>
      <guid>https://dev.to/mohammadrrashid/how-we-keep-mobile-session-replay-17x-cheaper-than-posthog-d5k</guid>
      <description>&lt;h2&gt;
  
  
  How We Keep Mobile Session Replay 17× Cheaper Than PostHog
&lt;/h2&gt;

&lt;p&gt;PostHog bills around &lt;strong&gt;$85/month for 25,000 sessions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Rejourney bills &lt;strong&gt;$5/month&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;At higher volumes, the gap gets even wider. At &lt;strong&gt;350,000 sessions/month&lt;/strong&gt;, Rejourney is roughly &lt;strong&gt;20× cheaper&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This post is not about pricing strategy but why those numbers are technically sustainable.&lt;/p&gt;

&lt;p&gt;The answer is not one trick. It is a stack of engineering decisions that each remove a unit of cost that would otherwise compound with volume.&lt;/p&gt;

&lt;h2&gt;
  
  
  Price Comparison
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sessions / Month&lt;/th&gt;
&lt;th&gt;Rejourney&lt;/th&gt;
&lt;th&gt;PostHog&lt;/th&gt;
&lt;th&gt;Cheaper By&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;25,000&lt;/td&gt;
&lt;td&gt;$5/mo&lt;/td&gt;
&lt;td&gt;$85/mo&lt;/td&gt;
&lt;td&gt;17×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100,000&lt;/td&gt;
&lt;td&gt;$15/mo&lt;/td&gt;
&lt;td&gt;$272.50/mo&lt;/td&gt;
&lt;td&gt;18×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;350,000&lt;/td&gt;
&lt;td&gt;$35/mo&lt;/td&gt;
&lt;td&gt;$712.50/mo&lt;/td&gt;
&lt;td&gt;20×&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  1. SDK Bandwidth: Every Byte Has to Be Stored and Served
&lt;/h2&gt;

&lt;p&gt;Most session replay tools capture at the device’s native resolution because it is the simplest implementation.&lt;/p&gt;

&lt;p&gt;We do not.&lt;/p&gt;

&lt;p&gt;The Rejourney SDK captures at &lt;strong&gt;1.25× scale&lt;/strong&gt;, meaning we read the framebuffer at roughly 80% of its linear dimension before compression.&lt;/p&gt;

&lt;p&gt;Compared with &lt;strong&gt;3× Retina&lt;/strong&gt;, that reduces raw pixel count by about &lt;strong&gt;5.8×&lt;/strong&gt; before JPEG compression even begins.&lt;/p&gt;

&lt;p&gt;That matters because every pixel captured by the SDK eventually becomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU work&lt;/li&gt;
&lt;li&gt;memory pressure&lt;/li&gt;
&lt;li&gt;upload bandwidth&lt;/li&gt;
&lt;li&gt;object storage&lt;/li&gt;
&lt;li&gt;replay egress&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The frame rate is also intentionally conservative.&lt;/p&gt;

&lt;p&gt;Our default is &lt;strong&gt;1 frame per second&lt;/strong&gt;. The capture timer runs in UIKit’s default run loop mode instead of &lt;code&gt;.common&lt;/code&gt;, which means the timer naturally pauses while UIKit handles active scroll events.&lt;/p&gt;

&lt;p&gt;We are not manually slowing down during scrolls. The run loop simply does not fire the timer.&lt;/p&gt;

&lt;p&gt;A tool capturing at 10 FPS can easily generate around &lt;strong&gt;10× more screenshot data per session&lt;/strong&gt; before any other cost factor is considered.&lt;/p&gt;

&lt;h3&gt;
  
  
  Background Encoding and Backpressure
&lt;/h3&gt;

&lt;p&gt;The main thread is only involved for the pixel read.&lt;/p&gt;

&lt;p&gt;Everything else runs on a serial background &lt;code&gt;OperationQueue&lt;/code&gt; at &lt;code&gt;.utility&lt;/code&gt; QoS:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JPEG encoding&lt;/li&gt;
&lt;li&gt;frame batching&lt;/li&gt;
&lt;li&gt;gzip compression&lt;/li&gt;
&lt;li&gt;HTTP upload&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The encode queue also has hard backpressure limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;50 pending batches&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;500 buffered frames&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When either limit is reached, new frames are dropped instead of queued indefinitely.&lt;/p&gt;

&lt;p&gt;That prevents a network outage from becoming unbounded memory growth.&lt;/p&gt;

&lt;h3&gt;
  
  
  On-Device Redaction
&lt;/h3&gt;

&lt;p&gt;Redaction happens before encoding.&lt;/p&gt;

&lt;p&gt;Text inputs, password fields, and camera previews are blacked out directly in the pixel buffer before the JPEG encoder runs.&lt;/p&gt;

&lt;p&gt;That means sensitive pixels never leave the device and never enter the artifact.&lt;/p&gt;

&lt;p&gt;It also removes the need for a server-side blurring pipeline, which means one less compute stage and one less storage operation per session.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Compression: Binary Frame Bundles + Gzip
&lt;/h2&gt;

&lt;p&gt;Frames are not uploaded individually.&lt;/p&gt;

&lt;p&gt;After JPEG encoding, frames are packed into a binary archive and gzip-compressed as a single unit.&lt;/p&gt;

&lt;p&gt;The binary format is deliberately simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ 8 bytes — uint64 BE ] timestamp offset from session epoch, in ms
[ 4 bytes — uint32 BE ] JPEG byte length
[ N bytes            ] raw JPEG data

...repeated for each frame in the batch...

→ entire archive passed to gzipCompress()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is no alignment padding and no unnecessary per-frame metadata.&lt;/p&gt;

&lt;p&gt;The gzip pass uses zlib’s &lt;code&gt;deflateInit2_&lt;/code&gt; with compression level 9.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="nf"&gt;deflateInit2_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;               &lt;span class="c1"&gt;// Z_BEST_COMPRESSION&lt;/span&gt;
    &lt;span class="kt"&gt;Z_DEFLATED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;MAX_WBITS&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// gzip container&lt;/span&gt;
    &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;               &lt;span class="c1"&gt;// memLevel&lt;/span&gt;
    &lt;span class="kt"&gt;Z_DEFAULT_STRATEGY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;ZLIB_VERSION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;MemoryLayout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;z_stream&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Level 9 costs more CPU than level 6, but for our workload, the tradeoff is worth it.&lt;/p&gt;

&lt;p&gt;The compression work runs at &lt;code&gt;.utility&lt;/code&gt; QoS, so it happens on background CPU. The smaller payload wins later at the storage and egress layer every time the artifact is read back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Flush Behavior
&lt;/h3&gt;

&lt;p&gt;Batches flush when either condition is met:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The buffer reaches the upload batch size, defaulting to 3 frames.&lt;/li&gt;
&lt;li&gt;The oldest buffered frame has waited longer than &lt;code&gt;batchSize × snapshotInterval&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The time-based flush is specifically for short sessions.&lt;/p&gt;

&lt;p&gt;Without it, a 2-second session could end before ever accumulating a full batch.&lt;/p&gt;

&lt;p&gt;Hierarchy snapshots go through the same gzip compression path independently, so every artifact type leaving the device is compressed.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Ingest Pipeline: Object Storage Is Not in the SDK Request Path
&lt;/h2&gt;

&lt;p&gt;A common session replay ingest pattern looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SDK upload
→ server presigns PUT URL
→ SDK uploads to object storage
→ server records artifact metadata
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That makes object storage latency part of the SDK upload path.&lt;/p&gt;

&lt;p&gt;If S3 is slow, the ingest service is slow.&lt;/p&gt;

&lt;p&gt;We separate those concerns.&lt;/p&gt;

&lt;p&gt;When the SDK uploads an artifact body, the ingest relay writes it into Redis under:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;artifact:buf:{artifactId}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with a 30-minute TTL, then immediately returns &lt;code&gt;204&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The SDK is done in under 50ms regardless of what object storage is doing.&lt;/p&gt;

&lt;p&gt;Actual object storage writes happen asynchronously through a BullMQ worker on the &lt;code&gt;rj-artifact-flush&lt;/code&gt; queue.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why This Works
&lt;/h3&gt;

&lt;p&gt;BullMQ deduplicates flush jobs by &lt;code&gt;artifactId&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If a worker crashes mid-flush, the job becomes stalled and is automatically requeued after 30 seconds for up to three attempts.&lt;/p&gt;

&lt;p&gt;The flush operation is idempotent. Writing the same artifact to object storage twice is safe.&lt;/p&gt;

&lt;p&gt;Redis TTL acts as a circuit breaker. If the artifact is not flushed within 30 minutes, it is dropped rather than left orphaned.&lt;/p&gt;

&lt;p&gt;In practice, flush jobs complete in seconds. The TTL exists for pathological failure, not normal operation.&lt;/p&gt;

&lt;p&gt;The result is that the ingest relay pod stays stateless and cheap.&lt;/p&gt;

&lt;p&gt;It never waits on object storage latency and scales horizontally with upload volume.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Storage Routing: No Hard-Coded Buckets
&lt;/h2&gt;

&lt;p&gt;Every artifact is pinned to the endpoint that received it through a &lt;code&gt;storage_endpoints&lt;/code&gt; table in Postgres.&lt;/p&gt;

&lt;p&gt;At write time, the flush worker resolves an endpoint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;project-specific override, or&lt;/li&gt;
&lt;li&gt;global default selected by weight&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It writes the artifact, then stores the endpoint ID with the artifact metadata.&lt;/p&gt;

&lt;p&gt;Reads always look up the endpoint from the artifact record instead of assuming one global bucket.&lt;/p&gt;

&lt;p&gt;That makes bucket migration operational instead of architectural.&lt;/p&gt;

&lt;p&gt;We can add a new endpoint, shift its weight to 100%, and drain the old bucket without changing application code or breaking old artifacts.&lt;/p&gt;

&lt;p&gt;Every artifact knows where it lives.&lt;/p&gt;

&lt;h3&gt;
  
  
  Current Storage Strategy
&lt;/h3&gt;

&lt;p&gt;Our current provider is OVH.&lt;/p&gt;

&lt;p&gt;The main reasons are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cheap storage&lt;/li&gt;
&lt;li&gt;free egress&lt;/li&gt;
&lt;li&gt;free ingress&lt;/li&gt;
&lt;li&gt;no API operation costs&lt;/li&gt;
&lt;li&gt;mature object storage platform&lt;/li&gt;
&lt;li&gt;high object-count tolerance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After the primary write, shadow endpoints receive async copies for durability without slowing down the hot path.&lt;/p&gt;

&lt;p&gt;Postgres WAL archiving and compressed database backups go to Cloudflare R2, where zero-egress reads are useful for rare backup and archival access.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Database: CloudNativePG Instead of Managed Databases
&lt;/h2&gt;

&lt;p&gt;Managed database services like RDS, Cloud SQL, and Supabase charge a premium for operations.&lt;/p&gt;

&lt;p&gt;We run Postgres using &lt;strong&gt;CloudNativePG&lt;/strong&gt;, the CNCF-graduated Kubernetes operator for Postgres.&lt;/p&gt;

&lt;p&gt;Our setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;primary Postgres instance in one datacenter&lt;/li&gt;
&lt;li&gt;synchronous standby in a second datacenter&lt;/li&gt;
&lt;li&gt;&lt;code&gt;synchronous_commit = remote_write&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;pgbouncer in front of Postgres&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With &lt;code&gt;remote_write&lt;/code&gt;, the standby has the write before the primary acknowledges it. If the primary fails, auto-promotion takes roughly 30 seconds, and pgbouncer follows the new primary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why pgbouncer Matters
&lt;/h3&gt;

&lt;p&gt;Session replay ingest creates many short-lived database interactions.&lt;/p&gt;

&lt;p&gt;Each worker job may open and release a database connection.&lt;/p&gt;

&lt;p&gt;Without pooling, Postgres would waste CPU on connection setup and teardown.&lt;/p&gt;

&lt;p&gt;pgbouncer keeps around 180 connections to Postgres while exposing a higher connection limit to the application layer.&lt;/p&gt;

&lt;p&gt;That keeps Postgres focused on query work instead of connection churn.&lt;/p&gt;

&lt;h3&gt;
  
  
  Redis HA
&lt;/h3&gt;

&lt;p&gt;Redis runs as a three-node Sentinel cluster.&lt;/p&gt;

&lt;p&gt;Sentinel requires a quorum of 2 out of 3 nodes to elect a new master.&lt;/p&gt;

&lt;p&gt;One important configuration choice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;maxmemory-policy = noeviction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For BullMQ job state, silent eviction would be dangerous. It could make jobs disappear without processing.&lt;/p&gt;

&lt;p&gt;Instead, Redis returns an error when memory is full, and we treat that as a backpressure signal.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Compute: k3s on European VPS Instead of Managed Kubernetes
&lt;/h2&gt;

&lt;p&gt;Managed Kubernetes on AWS, GCP, or Azure has two major costs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the worker nodes&lt;/li&gt;
&lt;li&gt;the managed control plane&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The control plane fee is fixed regardless of load, and full Kubernetes distributions can consume several gigabytes of RAM per node before application pods even run.&lt;/p&gt;

&lt;p&gt;We use &lt;strong&gt;k3s&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;k3s ships as a single binary, embeds etcd, and has a much smaller memory footprint.&lt;/p&gt;

&lt;p&gt;That means more of the machine’s RAM goes to actual workloads.&lt;/p&gt;

&lt;p&gt;We run the cluster on Hetzner across two EU datacenters.&lt;/p&gt;

&lt;p&gt;Worker workloads that process bulk session artifacts run in the second datacenter, keeping the primary node’s CPU available for lower-latency API traffic.&lt;/p&gt;

&lt;p&gt;These workers are mostly I/O-bound, so they autoscale on BullMQ queue depth instead of CPU utilization.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. GDPR Data Residency
&lt;/h2&gt;

&lt;p&gt;The infrastructure is designed around EU data residency.&lt;/p&gt;

&lt;p&gt;The ingest path is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SDK
→ Cloudflare WAF
→ load balancer
→ Rejourney API
→ Redis / Postgres / object storage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All compute runs in the EU, primarily Germany and Finland.&lt;/p&gt;

&lt;p&gt;Cloudflare is used for TLS termination and WAF behavior, not persistent session replay storage.&lt;/p&gt;

&lt;p&gt;The iOS SDK also ships with &lt;code&gt;PrivacyInfo.xcprivacy&lt;/code&gt;, so App Store privacy API usage declarations are handled automatically.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The cost difference comes from reducing cost at every layer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fewer pixels captured&lt;/li&gt;
&lt;li&gt;lower frame rate&lt;/li&gt;
&lt;li&gt;background compression&lt;/li&gt;
&lt;li&gt;strict SDK backpressure&lt;/li&gt;
&lt;li&gt;on-device redaction&lt;/li&gt;
&lt;li&gt;binary frame bundles&lt;/li&gt;
&lt;li&gt;Redis-buffered ingest&lt;/li&gt;
&lt;li&gt;async object storage flushing&lt;/li&gt;
&lt;li&gt;endpoint-aware storage routing&lt;/li&gt;
&lt;li&gt;self-operated Postgres with CloudNativePG&lt;/li&gt;
&lt;li&gt;k3s instead of managed Kubernetes&lt;/li&gt;
&lt;li&gt;EU VPS infrastructure&lt;/li&gt;
&lt;li&gt;storage providers selected for low egress and operational flexibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Session replay is expensive when every session creates too much data and every request touches too many expensive systems.&lt;/p&gt;

&lt;p&gt;Rejourney stays cheap because the expensive parts are avoided, compressed, delayed, or moved out of the hot path.&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>sessionreplay</category>
      <category>reactnative</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Rejourney Session Replay Now Open Beta for Swift</title>
      <dc:creator>Mohammad R. Rashid</dc:creator>
      <pubDate>Tue, 05 May 2026 19:20:45 +0000</pubDate>
      <link>https://dev.to/mohammadrrashid/rejourney-session-replay-now-open-beta-for-swift-3m1i</link>
      <guid>https://dev.to/mohammadrrashid/rejourney-session-replay-now-open-beta-for-swift-3m1i</guid>
      <description>&lt;p&gt;After nearly 3 months of battle testing our React Native package, and recording over 1.5 million session replays from users all over the world, we now have public open beta for our Swift Package.&lt;/p&gt;

&lt;p&gt;The Swift package follows a lot of the design decisions for React Native iOS as that was also built in Native Swift for performance. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9p6u3rlby37u3t80vlxc.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9p6u3rlby37u3t80vlxc.webp" alt=" " width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Reused From React Native
&lt;/h2&gt;

&lt;p&gt;Our React Native package is where the recorder became boring in the best sense. It forced the native iOS and Android engines to survive real app startup races, navigation churn, background/foreground rollover, custom URLSession stacks, offline uploads, and aggressively animated screens. The Swift Package keeps that native core model.&lt;/p&gt;

&lt;p&gt;The reusable unit was never the JavaScript API. The reusable unit was the native capture pipeline: DeviceRegistrar establishes identity and upload credentials,ReplayOrchestrator owns the session state machine, VisualCaptureand ViewHierarchyScanner produce time-aligned artifacts, andSegmentDispatcher ships compressed payloads into the same production ingest routes used by React Native.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi3sq34zqltzs65k3kqnk.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi3sq34zqltzs65k3kqnk.webp" alt=" " width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Direction From Here
&lt;/h2&gt;

&lt;p&gt;The Swift Package lets us treat native iOS as a first-class integration target instead of a platform implementation detail behind React Native. The important part is that we got there without forking the product model: sessions, artifacts, replay timelines, upload credentials, sampling, observe-only mode, and backend finalization still speak the same protocol.&lt;/p&gt;

&lt;p&gt;That is the architectural line we want to keep: different host runtimes, shared replay semantics. React Native will continue to drive cross-platform ergonomics. SwiftPM will let us go deeper on iOS-specific correctness, performance, and privacy. The beta is the point where those two tracks stop blocking each other.&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>ios</category>
      <category>swift</category>
    </item>
    <item>
      <title>How we scaled to 1.3 MILLION Session Replays</title>
      <dc:creator>Mohammad R. Rashid</dc:creator>
      <pubDate>Fri, 24 Apr 2026 02:23:41 +0000</pubDate>
      <link>https://dev.to/mohammadrrashid/how-we-scaled-to-13-million-session-replays-54c2</link>
      <guid>https://dev.to/mohammadrrashid/how-we-scaled-to-13-million-session-replays-54c2</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8awcn6ada8eyt2wzky6d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8awcn6ada8eyt2wzky6d.png" alt=" " width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.tourl"&gt;Rejourney.co&lt;/a&gt; has scaled to over 1.3 MILLION session replays from app developers over the world.&lt;/p&gt;

&lt;p&gt;Rejourney is an alternative to sentry.io and posthog.com for indie React Native developers. &lt;/p&gt;

&lt;p&gt;Quick growth for any startup is hard. However, the difficulty is far greater when your startup handles hundreds to thousands of small files ingested every minute. Every startup dreams of that "hockey stick" moment, but as we recently learned at Rejourney, the infrastructure that supports 10,000 sessions a day doesn't always handle 100,000 with the same grace.  &lt;/p&gt;

&lt;p&gt;Last month, we officially onboarded new customers with expansive user bases across several high-traffic mobile apps. It was a milestone for our team, but it also quickly became an "all-hands-on-deck" engineering challenge.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The "Accidental" DDoS
&lt;/h2&gt;

&lt;p&gt;The trouble started almost immediately after they loaded Rejourney live on their apps. Within minutes, our ingestion metrics spiked by an order of magnitude.  &lt;/p&gt;

&lt;p&gt;At the edge, Cloudflare’s automated security systems saw this sudden, massive influx of traffic to our API and did exactly what they were programmed to do: they flagged it as a Distributed Denial of Service (DDoS) attack. Legitimate session data from thousands of users was being dropped before it even reached our infrastructure.  &lt;/p&gt;

&lt;p&gt;Our immediate fix was to implement a bypass filter for our specific API endpoint. We wanted to ensure no data was lost and that the onboarding experience was seamless. We flipped the switch, the "Attack Mode" subsided, and the floodgates opened.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Thundering Herd
&lt;/h2&gt;

&lt;p&gt;Opening the floodgates is only a good idea if your reservoir can handle the volume. By bypassing the edge protection, we redirected the full, unthrottled weight of the traffic directly to our origin server.  &lt;/p&gt;

&lt;p&gt;At the time, our backend was running on a single-node K3s cluster. While we’ve optimized our ingestion pipeline to be lean, no single node is immune to a "thundering herd." As thousands of concurrent connections hit our API, our Ingest Pods were pinned at Max CPU, and the server eventually became unresponsive.  &lt;/p&gt;

&lt;p&gt;We realized that scaling "up" (getting a bigger VPS) was no longer enough. We needed to scale "out."  &lt;/p&gt;

&lt;h2&gt;
  
  
  Decomposing the Ingestion Pipeline
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61865pi70g015c9ruphl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61865pi70g015c9ruphl.png" alt=" " width="671" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Session lifecycle architecture from SDK start through upload lanes, workers, and reconciliation&lt;br&gt;&lt;br&gt;
Session lifecycle overview: upload lanes, durable queue boundary, workers, and reconciliation.  &lt;/p&gt;

&lt;p&gt;The biggest bottleneck in our old setup was the "monolithic" nature of ingestion. If a pod restarted, in-memory tasks were lost. We’ve now decomposed the pipeline into five specialized, durable stages:  &lt;/p&gt;

&lt;p&gt;The Control Plane (API): Our API pods now focus exclusively on the "handshake." When the SDK calls our endpoints, we immediately create durable rows in Postgres (via PgBouncer) to track the session and ingest jobs.  &lt;/p&gt;

&lt;p&gt;The Upload Relay: We isolated heavy client upload traffic into its own ingest-upload layer. These pods act as a relay to Hetzner S3, ensuring that a flood of incoming bytes doesn't starve our core API of resources.  &lt;/p&gt;

&lt;p&gt;The Durable Queue Boundary: We moved away from in-memory task management. Work is now represented as durable rows in Postgres. If a worker pod crashes or restarts, the job still exists in the database, waiting to be claimed.  &lt;/p&gt;

&lt;p&gt;Specialized Worker Deployments: We split our processing power. ingest-workers handle lightweight metadata like events and crashes, while replay-workers tackle the heavy lifting of screenshots and hierarchies.  &lt;/p&gt;

&lt;p&gt;Self-Healing Reconciliation: A dedicated session-lifecycle-worker performs periodic sweeps to recover stuck states or abandon expired artifacts.  &lt;/p&gt;

&lt;p&gt;By using Postgres as the source of truth for state and S3 for storage, our system is now remarkably resilient. Even if Redis or individual pods face transient issues, the state survives and processing resumes exactly where it left off.  &lt;/p&gt;

&lt;h2&gt;
  
  
  High-Availability Postgres and Redis
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6dkk5emsi0x41hl331bv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6dkk5emsi0x41hl331bv.png" alt=" " width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We’ve moved away from the single-node bottleneck to a High Availability configuration. We now run HA Postgres and Redis with automated failover. If a VPS goes down, the databases automatically fall back to a replica. The platform keeps moving, and the data stays safe.  &lt;/p&gt;

&lt;p&gt;K3s cloud setup showing ingress, API, workers, and data services&lt;br&gt;&lt;br&gt;
K3s cloud setup: ingress, app services, workers, and HA data plane.  &lt;/p&gt;

&lt;p&gt;Before  &lt;/p&gt;

&lt;p&gt;Single-node Postgres and Redis tied to one VPS.&lt;br&gt;&lt;br&gt;
Infrastructure maintenance had direct outage risk.&lt;br&gt;&lt;br&gt;
No automated failover path during node loss.  &lt;/p&gt;

&lt;p&gt;After  &lt;/p&gt;

&lt;p&gt;HA Postgres and Redis replicated across nodes.&lt;br&gt;&lt;br&gt;
Automated failover promotes healthy replicas quickly.&lt;br&gt;&lt;br&gt;
Platform continuity during host-level interruptions.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Navigating the 50 Million Object Limit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp1ukjyvwhz7rzs1oqbde.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp1ukjyvwhz7rzs1oqbde.png" alt=" " width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we scaled, we hit a literal physical limit: providers like Hetzner often impose a 50-million-object limit per bucket. To bypass this, we implemented a dynamic multi-bucket topology.  &lt;/p&gt;

&lt;p&gt;Instead of hard-coding storage locations in environment variables, we moved the source of truth to a storage_endpoints table in Postgres. This allows us to manage storage with extreme granularity:  &lt;/p&gt;

&lt;p&gt;Multi-bucket topology with endpoint resolution, artifact pinning, and shadow replication&lt;br&gt;&lt;br&gt;
Multi-bucket topology: endpoint routing, artifact pinning, and shadow durability.  &lt;/p&gt;

&lt;p&gt;Weighted Traffic Splitting: We can resolve active buckets and perform weighted random selection to balance load across providers.  &lt;/p&gt;

&lt;p&gt;Artifact Pinning: To avoid "File Not Found" errors during migrations, we store the specific endpoint_id on every artifact. This "pins" future reads to the correct bucket, even as global defaults change.  &lt;/p&gt;

&lt;p&gt;Shadow Copies for Durability: We implemented a "Shadow" role. Once a primary write succeeds, we fan out asynchronous writes to shadow targets for extra redundancy.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Efficiency at Scale
&lt;/h2&gt;

&lt;p&gt;Despite the intensity of the traffic spike, we managed to implement these changes with less than five minutes of total downtime.  &lt;/p&gt;

&lt;p&gt;This incident reinforced why we focus so much on performance. Our lightweight SDK ensures we aren't taxing the user’s device, while our new HA infrastructure ensures we can handle whatever volume the next "hockey stick" growth moment throws at us.  &lt;/p&gt;

&lt;p&gt;We’re now back to 100% stability, with a much larger "reservoir" ready for the next wave of growth. If you’ve been looking for a session replay tool that respects your app’s performance as much as you do, we’re more ready for you than ever.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Rollout Timeline
&lt;/h2&gt;

&lt;p&gt;Detected false-positive edge protection and restored trusted API traffic.&lt;br&gt;&lt;br&gt;
Isolated upload traffic and shifted orchestration state to durable Postgres rows.&lt;br&gt;&lt;br&gt;
Split workers by workload, then added reconciliation for crash-safe recovery.&lt;br&gt;&lt;br&gt;
Enabled HA Postgres + Redis and finalized multi-bucket endpoint routing.  &lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>ux</category>
      <category>analytics</category>
      <category>ios</category>
    </item>
  </channel>
</rss>
