<?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: Süleyman Y</title>
    <description>The latest articles on DEV Community by Süleyman Y (@suleyman0).</description>
    <link>https://dev.to/suleyman0</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4213574%2F13f53de3-8413-4dc9-8c78-06bcf0dc400a.jpg</url>
      <title>DEV Community: Süleyman Y</title>
      <link>https://dev.to/suleyman0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/suleyman0"/>
    <language>en</language>
    <item>
      <title>Building a Zero-Retention Online PDF Toolkit: Architecture, Privacy &amp; Edge Hardware Optimization</title>
      <dc:creator>Süleyman Y</dc:creator>
      <pubDate>Wed, 28 Oct 2026 17:46:03 +0000</pubDate>
      <link>https://dev.to/suleyman0/building-a-zero-retention-online-pdf-toolkit-architecture-privacy-edge-hardware-optimization-4ma7</link>
      <guid>https://dev.to/suleyman0/building-a-zero-retention-online-pdf-toolkit-architecture-privacy-edge-hardware-optimization-4ma7</guid>
      <description>&lt;p&gt;Most web users don't think twice before uploading confidential tax records, bank statements, medical scans, or contract agreements to popular online PDF converter websites.&lt;/p&gt;

&lt;p&gt;Yet behind the scenes, many commercial platforms store uploaded documents on persistent cloud disks, parse metadata for analytics, or hold files for hours in S3 buckets before scheduled deletion.&lt;/p&gt;

&lt;p&gt;When building &lt;a href="https://webpdftools.org/" rel="noopener noreferrer"&gt;WebPDFTools.org&lt;/a&gt;, we set a strict architectural constraint: &lt;strong&gt;Zero File Retention&lt;/strong&gt;. Documents must be processed ephemerally in volatile memory or isolated scratch spaces, streamed back to the client, and purged instantly.&lt;/p&gt;

&lt;p&gt;Here is a look under the hood at our architecture, how we optimize CPU-heavy Ghostscript and Tesseract workloads on edge hardware, and how we handle concurrency without crashing the host.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. High-Level Architecture
&lt;/h2&gt;

&lt;p&gt;The platform runs a lightweight, decoupled stack designed for minimal overhead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ Client Browser ]
       |
       v (HTTPS / TLS 1.3 via Cloudflare Tunnel)
[ Reverse Proxy: Nginx (Container) ]
   +-- Static Landing Pages (Pure semantic HTML + CSS)
   +-- Rate Limiting &amp;amp; Burst Queuing (anti-flood buffer)
   +-- API Proxy (/api/v1/*)
       |
       v (Private Internal Docker Bridge)
[ Stirling-PDF Core Engine (JVM / Linux container) ]
   +-- Ghostscript (Optimization &amp;amp; Downsampling)
   +-- Tesseract OCR v5 (Searchable sandwich PDF generation)
   +-- QPDF &amp;amp; Apache PDFBox (Splitting, Merging, AES encryption)
   +-- LibreOffice Headless (Document conversion)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why Pure HTML/CSS for the Frontend?
&lt;/h3&gt;

&lt;p&gt;Instead of a heavy client-side Single Page Application (SPA) with megabytes of JavaScript bundles, our landing pages - such as &lt;a href="https://webpdftools.org/merge-pdf" rel="noopener noreferrer"&gt;PDF Merge&lt;/a&gt; and &lt;a href="https://webpdftools.org/compress-pdf" rel="noopener noreferrer"&gt;PDF Compress&lt;/a&gt; - are written in semantic, zero-dependency HTML5. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;First Contentful Paint (FCP):&lt;/strong&gt; Under 300ms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Core Web Vitals:&lt;/strong&gt; 100/100 performance score.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Browser Compatibility:&lt;/strong&gt; Works across any mobile browser without hydration lag.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Implementing the "Zero-Retention" Guarantee
&lt;/h2&gt;

&lt;p&gt;Ensuring documents are truly ephemeral requires defense-in-depth across the container and host storage:&lt;/p&gt;

&lt;h3&gt;
  
  
  A. Server-Side Storage Completely Disabled
&lt;/h3&gt;

&lt;p&gt;In the application configuration (&lt;code&gt;settings.yml&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This forces the backend engine to reject any database persistence or archive pipeline.&lt;/p&gt;

&lt;h3&gt;
  
  
  B. Ephemeral Mounting
&lt;/h3&gt;

&lt;p&gt;Volume mounts between the host and Docker containers are restricted strictly to read-only language dictionaries (&lt;code&gt;tessdata&lt;/code&gt;), system configuration files, and error logs. &lt;strong&gt;No upload directory is ever bound to the host disk.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  C. Automated Memory Sweeping
&lt;/h3&gt;

&lt;p&gt;Files reside in volatile RAM buffers (&lt;code&gt;/tmp/stirling-pdf&lt;/code&gt;) only while the transformation is actively executing. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As soon as the binary stream completes and HTTP headers close, the temp descriptor is unlinked.&lt;/li&gt;
&lt;li&gt;A background garbage collector daemon sweeps the scratch space every 30 minutes for orphaned file pointers.&lt;/li&gt;
&lt;li&gt;On container boot, all temporary namespaces are automatically purged.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Concurrency Control: Sequential Queuing on Edge Hardware
&lt;/h2&gt;

&lt;p&gt;One of the biggest challenges when self-hosting resource-intensive workloads (such as OCR or multi-page Ghostscript compression) on low-power edge machines (like ARM64 or Raspberry Pi 5 clusters) is &lt;strong&gt;CPU saturation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If 5 users simultaneously trigger a 300 DPI OCR scan or a 50-page document compression:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ghostscript and Tesseract will spawn threads across all available cores.&lt;/li&gt;
&lt;li&gt;CPU usage hits 100%, causing thermal throttling.&lt;/li&gt;
&lt;li&gt;Essential background services (like reverse proxies or home automation) begin dropping connections.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To solve this, we implemented a &lt;strong&gt;3-tier traffic-shaping pipeline&lt;/strong&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Engine-Level Process Semaphore
&lt;/h3&gt;

&lt;p&gt;We dialed back concurrent worker limits inside the application engine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;processExecutor&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;sessionLimit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;libreOfficeSessionLimit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
    &lt;span class="na"&gt;tesseractSessionLimit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
    &lt;span class="na"&gt;ghostscriptSessionLimit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# Was 8: Now strictly sequential&lt;/span&gt;
    &lt;span class="na"&gt;ocrMyPdfSessionLimit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
    &lt;span class="na"&gt;qpdfSessionLimit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;         &lt;span class="c1"&gt;# Lightweight ops can run in pairs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When multiple requests arrive, subsequent operations do not fail with errors. Instead, they enter an internal JVM semaphore queue. Request B waits until Request A releases the worker, and completes smoothly.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Nginx Request Throttling &amp;amp; Buffer
&lt;/h3&gt;

&lt;p&gt;At the reverse proxy layer, burst traffic is buffered to prevent thread starvation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="c1"&gt;# nginx.conf&lt;/span&gt;
&lt;span class="k"&gt;limit_req_zone&lt;/span&gt; &lt;span class="nv"&gt;$binary_remote_addr&lt;/span&gt; &lt;span class="s"&gt;zone=pdf_proc_limit:10m&lt;/span&gt; &lt;span class="s"&gt;rate=2r/s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;# webpdftools.org.conf&lt;/span&gt;
&lt;span class="k"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/api/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;# Queue burst requests gracefully without rejection&lt;/span&gt;
    &lt;span class="kn"&gt;limit_req&lt;/span&gt; &lt;span class="s"&gt;zone=pdf_proc_limit&lt;/span&gt; &lt;span class="s"&gt;burst=10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;proxy_pass&lt;/span&gt; &lt;span class="s"&gt;http://stirling-pdf:8080/api/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;proxy_read_timeout&lt;/span&gt; &lt;span class="s"&gt;300s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the absence of the &lt;code&gt;nodelay&lt;/code&gt; flag: incoming bursts within the threshold are delayed and fed into the processing pipe at a steady, manageable rate.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Hard Container CPU Quotas
&lt;/h3&gt;

&lt;p&gt;In Docker Compose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stirling-pdf&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;stirlingtools/stirling-pdf:latest&lt;/span&gt;
    &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.0&lt;/span&gt;      &lt;span class="c1"&gt;# Hard ceiling: uses at most 2 cores&lt;/span&gt;
    &lt;span class="na"&gt;mem_limit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;4g&lt;/span&gt;  &lt;span class="c1"&gt;# Prevents OOM cascade&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This guarantees that even under maximum stress, at least 50% of host compute capacity remains completely untouched for the operating system and edge services.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Key Takeaways &amp;amp; Try It Out
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Privacy is an architectural choice:&lt;/strong&gt; You don't need cloud buckets or databases to build a scalable utility tool. Streaming and ephemeral processing provide superior user trust.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate-limiting is not just for security:&lt;/strong&gt; On edge hardware, using Nginx burst queues and engine semaphores prevents thermal collapse under unexpected traffic spikes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the web fast:&lt;/strong&gt; Dropping heavy client JS frameworks for utilities yields massive improvements in user experience and Core Web Vitals.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Check out the live implementation at &lt;a href="https://webpdftools.org/" rel="noopener noreferrer"&gt;WebPDFTools.org&lt;/a&gt; and let us know your thoughts on the architecture in the comments below!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>privacy</category>
      <category>architecture</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
