惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
WordPress大学
WordPress大学
H
Help Net Security
小众软件
小众软件
N
Netflix TechBlog - Medium
C
Check Point Blog
量子位
Last Week in AI
Last Week in AI
GbyAI
GbyAI
Martin Fowler
Martin Fowler
M
MIT News - Artificial intelligence
博客园 - 聂微东
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
D
DataBreaches.Net
Project Zero
Project Zero
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
Security Latest
Security Latest
Cisco Talos Blog
Cisco Talos Blog
Recorded Future
Recorded Future
I
Intezer
L
Lohrmann on Cybersecurity
Cyberwarzone
Cyberwarzone
博客园_首页
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
P
Palo Alto Networks Blog
V
V2EX
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
The Exploit Database - CXSecurity.com
The Hacker News
The Hacker News
Blog — PlanetScale
Blog — PlanetScale
G
GRAHAM CLULEY
T
The Blog of Author Tim Ferriss
C
Cisco Blogs
The Register - Security
The Register - Security
L
LINUX DO - 热门话题
P
Privacy & Cybersecurity Law Blog
Scott Helme
Scott Helme
F
Full Disclosure
博客园 - 司徒正美
Recent Announcements
Recent Announcements
IT之家
IT之家
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Attack and Defense Labs
Attack and Defense Labs
Cloudbric
Cloudbric
Help Net Security
Help Net Security
The Last Watchdog
The Last Watchdog

Inside Nutrient

A guide to the invisible work behind documents Introducing Nutrient Documents for Salesforce: Native document generation and signing Document AI vs. traditional OCR: Choosing between OCR, AI, and hybrid pipelines PDF SDK compliance and security evaluation checklist for enterprise teams (2026) Invariant Corp replaces paper processes with Nutrient Workflow and scales without limits What is process mapping? A complete guide Nutrient vs. Conga Composer for Salesforce document generation (2026) Document routing: How to automate document distribution The CTO’s AI playbook: Why accountability architecture beats orchestration Compliance workflow automation: Why built-in compliance is table stakes Workflow diagrams: Examples, symbols, and how to build one that actually runs Digital forms: Replace paper forms with automated workflows Approval workflow software: How to automate approvals Why document-centric automation is different The CEO’s AI playbook: Why decision architecture beats model selection Nutrient SDK product updates for Q1 2026 PDF redaction verification: How to prove sensitive data is permanently removed What is a VPAT? The complete guide to accessibility conformance reports What is PDF/UA? The accessible PDF standard explained Salesforce eSignatures: Generate, sign, and track documents in one flow Online document viewer: Options, tradeoffs, and how to embed one Document viewer for web apps: React, Vue, Angular (2026) Best document viewers in 2026: A buyer’s guide How to edit a PDF in Python: Add text, images, and annotations Nutrient advances Workflow platform with agentic AI for enterprise-grade speed and consistency in document-heavy operations How to create a Salesforce quote template from opportunity data The business case for accessibility: Five ways it drives enterprise value Python PDF library comparison (2026): 7 libraries for developers Why your AI agent hallucinates PDF table data PDF.js limitations: When to upgrade to a commercial PDF SDK How Subject scaled 5× with Nutrient’s PDF SDK without rebuilding its document layer I replaced our sales training with an AI coach that runs in Slack — here’s what broke Redirecting to: https://securitybuzz.com/cybersecurity-news/why-enterprise-permissions-are-ais-most-dangerous-inheritance/ Nutrient .NET SDK vs. iText Core: Complete comparison for .NET developers DocuVieware: Support’s most frequently asked setup questions Introducing Nutrient Workflow How to convert PDF to Word in C# (.NET) When email and spreadsheets stop working: Work order approval workflows for field teams on the move Compliance with confidence: Why document-centric automation is the foundation of your mission Nutrient expands AI Assistant, automating multistep document workflows inside any application What is document generation? A developer’s guide to PDF generation Document Converter data flow and how real-time watermarks skip the queue PDF/UA compliance guide: Requirements, standards, and best practices Computers still can’t understand you How Athena Intelligence built AI agents for regulated enterprises with Nutrient’s document infrastructure How to convert HTML to PDF (2026): 4 methods from browser print to SDK How to build a document extraction pipeline with Nutrient Vision API OCR vs. intelligent document processing: Choosing the right document extraction engine Beyond OCR: How document intelligence eliminates manual processing in regulated industries Nutrient vs. IronPDF: Complete comparison for .NET developers Nutrient vs. Aspose.PDF: Complete comparison for .NET developers Redirecting to: https://fortune.com/2026/02/19/openclaw-who-is-peter-steinberger-openai-sam-altman-anthropic-moltbook/ Lufthansa Systems uses Nutrient to deliver reliable, scalable PDF rendering for pilots worldwide Nutrient vs. Syncfusion: Complete comparison for .NET developers React’s useTransition: The hook you’re probably using wrong First City Monument Bank streamlines banking processes with Nutrient Workflow Redirecting to: https://www.sdcexec.com/warehousing/automation/article/22957364/nutrient-workflow-automation-the-missing-link-in-supply-chain-efficiency The complete guide to digital signatures: PAdES, CAdES, and XAdES explained Nutrient Python SDK: Production-grade document processing for Python Introducing agentic document editing for web applications with AI Assistant Nutrient vs. QuestPDF: Complete comparison for .NET developers How we fixed the GdPicture license expiration (and what to do if you’re affected) Red team security testing with agentic AI The future of healthcare document automation Best healthcare workflow software compared Nutrient SDK product updates for Q4 2025 How Harvey scaled legal document workflows 50 percent MoM without rebuilding infrastructure HIPAA-compliant document management in hospitals How we optimized rendering performance while handling thousands of annotations in React — Part 2 Automated PII removal with Nutrient API Redirecting to: https://www.devopsdigest.com/2026-low-code-no-code-predictions Redirecting to: https://www.kmworld.com/Articles/Editorial/ViewPoints/Leaders-predict-AI-to-continue-permeating-all-aspects-of-KM-in-2026-172594.aspx What are deep agents and how do they solve complex problems? Whipping up document magic: Your easy-bake recipe for Vue and Nutrient Web SDK 🧁 What I’ve learned about product iteration planning while building SDKs Passwordless document signing: Three-layer security guide New zip folder functionality streamlines file management in Document Automation Server The keyboard shortcuts playbook: Taking control of keyboard events in Nutrient Web SDK From experienced engineer to AI beginner: My unexpected journey AI-assisted manual testing: Handling Safari’s PDF rendering and UI quirks How to keep a 20-year-old SDK up to date How we optimized rendering performance while handling thousands of annotations in React — Part 1 Nutrient announces new executive hires to accelerate next phase of growth High performance UI using web workers Automate document conversion at scale with Python and Nutrient DCS From curiosity to PLG (and AI): My journey to understanding product-led growth Prost to progress: One year as Nutrient Pigeon usage at Nutrient: Bridging native SDKs to Flutter Modernizing CI build servers: How to migrate from Chef to Ansible Unix man pages: AI-friendly documentation since 1971 Best AI redaction APIs: Complete comparison guide for 2025 Why AI document redaction matters for modern security From coding to coordinating: How AI transformed my workflow What is intelligent document processing (IDP)? A complete guide Enterprise PDF SDKs: Best PSPDFKit (now Nutrient) alternatives Nutrient SDK product updates for Q3 2025 GdPicture support best practices Redacting sensitive data with Nutrient AI redaction API How AI is transforming the customer experience at Nutrient: From instant answers to intelligent support How manual QA uses PR testing between releases
Consistent hashing for even load distribution
Bartosz Szafran · 2025-11-24 · via Inside Nutrient

Document Engine is a Nutrient platform designed to provide a complete SDK for managing the full lifecycle of a document — from storing or generating a document, through viewing and editing, to exporting from the system.

It’s a solution for managing massive amounts of documents while providing concurrent access for thousands of users. This, however, raises a fundamental challenge Document Engine needs to address: How can we effectively provide access to all resources?

Document storage and the caching challenge

An ordinary block storage-based file system isn’t suitable for storing documents. When uploading a document to Document Engine, the file is stored either directly in a Postgres database or in one of the configured asset storages. We currently support AWS S3 (and compatible services) and Azure Blob Storage.

This provides good storage capabilities; however, it doesn’t enable us to handle documents directly.

On every access to a document, it needs to be downloaded from asset storage. Only after that can it be loaded fully or partially into memory — for example, for rendering. In this scenario, the time to access a document is largely limited by two factors: transfer bandwidth and document size.

A simple mitigation for this problem is a file system cache that keeps the document on the local file system after it has been downloaded. That’s where Document Engine comes in.

Document Engine uses a least recently used (LRU) cache, which keeps documents on the local file system while keeping the total cache size within a configurable limit. When the limit is reached, the least recently accessed cached documents are removed.

This effectively enables data locality, meaning documents that are accessed more often are kept in the cache and don’t need to be downloaded from asset storage.

The scaling problem: When caching breaks down

This solution is efficient at low scale, but as the number of documents and users accessing them increases, it approaches the limits of this performance optimization.

While this issue isn’t as noticeable for small documents that can be quickly downloaded and cached, it becomes a significant problem for large documents, where download times can reach several seconds or even minutes. When the system stores tens of terabytes and the access pattern to documents is uniform, the cache hit rate drops dramatically. Large documents are frequently evicted from the cache before they can be reused, forcing repeated downloads from asset storage and severely impacting user experience.

Cache size for a Document Engine installation with an 8GB cache configured, before.

The figure above shows the cache size for a Document Engine installation with an 8GB cache configured. The cache grows constantly and periodically gets reduced when the LRU algorithm triggers, clearing 30 percent of the cached storage space by removing the least recently used documents. This pattern suggests that the miss rate is very high and files need to be downloaded from asset storage frequently.

Adding more nodes to the cluster won’t help with performance, as requests aren’t routed by document IDs but are instead uniformly distributed across the cluster. This means that different nodes are handling the same documents, which results in the cache being duplicated across nodes. Each node maintains its own separate cache, so popular documents end up being stored multiple times across different nodes, wasting precious cache space.

Moreover, when a user requests a document that was previously cached on a different node, it still needs to be downloaded from asset storage, defeating the purpose of caching. This leads to poor cache utilization and increased network traffic to asset storage.

How can data locality be ensured in such an environment?

Enter consistent hashing

The naive solution would be to increase the cache size. Unfortunately, this isn’t always possible, and it raises the question: How much cache is enough? Besides, the cache size needs to be increased across all nodes, which means ephemeral storage consumption is multiplied by the number of nodes in the cluster.

The solution to this problem is to use the consistent hashing algorithm. Consistent hashing is a technique that allows you to distribute the load evenly across multiple nodes. It’s used in many distributed systems, such as caches, databases, and file systems. The idea is to use a hash function to map documents to shards. This way, documents are evenly distributed across the shards, the load is balanced, and duplication is mitigated.

First, we need to define the shards. Document Engine is designed to run in a cluster, which means multiple instances of Document Engine can run at the same time. A shard represents the part of the hash value space that should be assigned to a given Document Engine node. The instances of Document Engine are identified by their unique IDs, which are used to place them in the hash value space. It’s as simple as hashing the node’s ID.

For each document, we need to calculate the hash value using the consistent hashing algorithm. The hash value is then used to determine which shard the document belongs to by finding the “next” value in the hash value space belonging to a Document Engine instance.

But what if there’s no “next” shard? Which shard should the document be assigned to? In this case, the algorithm wraps around to the beginning of the hash space and selects the first shard (represented by the node with the smallest hash value).

This wraparound behavior is what makes the hash space “circular.” As shown in the diagram below, the hash space goes from 0 to some maximum (4,294,967,295 (2^32) in the diagram) and then wraps back to 0. That’s why the hash space is commonly referred to as a “hash ring.”

This ensures that every document is always assigned to exactly one node, regardless of its hash value.

Hash ring

Hash space: 0 ────────────────────────────────────── 4,294,967,295 (2^32)

(wraps around)

0 2,147,483,648 4,294,967,295

| | |

▼ ▼ ▼

┌─────────────────────────────────────────────────────────────────┐

│ A B C │

│ │ │ │ │

└─────────┼──────────────────────┼──────────────────────┼─────────┘

│ │ │

Node A Node B Node C

(hash: 500M) (hash: 2.1B) (hash: 3.8B)

When we want to store a document, after assigning it a unique ID, we can calculate the hash value of the ID and find the closest node in the hash ring:

Document: "document.pdf"

┌───────────┐

│ hash(key) │ ──► Hash: 1,500,000,000

└───────────┘

┌───────────────────────────────────────────┐

│ Find first shard ≥ 1,500,000,000 in ring │

└───────────────────────────────────────────┘

Ring position: 2,147,483,648

┌─────────────┐

│ Node B │ ◄── Document handled by this node

└─────────────┘

The new document hash is 1,500,000,000, so we find the corresponding shard in the hash ring. The next shard is Node B, which has a hash value of 2,147,483,648.

Let’s look at a different example. Say we have a document with a hash value of 4,000,000,000. Since all our nodes (A: 500M, B: 2.1B, C: 3.8B) have smaller hash values, there’s no next shard. In this case, the algorithm wraps around to the beginning of the ring and assigns the document to Node A (the first node, with hash value 500M). This wraparound behavior ensures every document always gets assigned to a node.

Now, when we want to access a document, we can calculate the hash value of the document ID, and by knowing the cluster topology, we can find the node responsible for the document without needing to access the node or even query the cluster.

Still, this solution has a problem with load distribution. The node names are randomly distributed across the hash space, which means some nodes may have more documents than others. In an extreme case, one node may have all the documents, while the others have none:

Hash space: 0 ────────────────────────────────────── 4,294,967,295 (2^32)

(wraps around)

0 2,147,483,648 4,294,967,295

| | |

▼ ▼ ▼

┌─────────────────────────────────────────────────────────────────┐

│ A B C │

│ │ │ │ │

└─────────┼──┼──┼─────────────────────────────────────────────────┘

│ │ └───────────────────────────────────────┐

│ └──────────────────┐ │

Node A Node B Node C

(hash: 500M) (hash: 501M) (hash: 502M)

In this case, the load isn’t evenly distributed across the nodes, which means some nodes may be overloaded while others are idle.

Hash ranges:

┌─────────────────┬────────────────────┬─────────────────────────────────┐

│ Range │ Assigned to node │ Percentage of hash space │

├─────────────────┼────────────────────┼─────────────────────────────────┤

│ 0 → 500M │ Node A │ 11.6% (500M/4.3B) │ ← OVERLOADED

│ 500M → 501M │ Node B │ 0.2% (1M /4.3B) │

│ 501M → 502M │ Node C │ 0.2% (1M /4.3B) │

│ 502M → 4.3B │ Node A (wraparound)│ 88.3% (500M/4.3B) │ ← OVERLOADED

└─────────────────┴────────────────────┴─────────────────────────────────┘

As a result, we’ll practically handle all the documents on Node A, while nodes B and C will be idle.

Solution: Virtual sharding

To solve this problem, we can assign more shards to each node. With this approach, it’s almost impossible to have a situation where one node has all the documents.

Instead of hashing the node IDs directly, we can hash the ID together with an integer — like {node_id, 0}, {node_id, 1}, {node_id, 2}, etc. — up to a configured limit. This way, we can create multiple virtual shards for each actual node, which will be evenly distributed across the hash space.

Here’s the hash ring structure (simplified — showing fewer shards than in reality):

Hash Space: 0 ────────────────────────────────────── 4,294,967,295 (2^32)

(wraps around)

0 1073741824 2147483648 3221225472

| | | |

▼ ▼ ▼ ▼

┌────────────────────────────────────────────────────────┐

│ A1 B2 A3 C1 B4 A5 C3 B6 │

│ │ │ │ │ │ │ │ │ │

└─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼────────┘

│ │ │ │ │ │ │ │

Node A Node B Node A Node C Node B Node A Node C Node B

A1, A3, A5 = Node A’s virtual shards (hash({node_a, 1}), etc.)

B2, B4, B6 = Node B’s virtual shards

C1, C3 = Node C’s virtual shards

Advantages of consistent hashing

Why is this approach better than just using a simple hash function? It would also distribute the documents across the nodes, right?

The main advantage of consistent hashing is that it allows you to add or remove nodes from the cluster without having to move all the documents.

With simple hashing:

my_node = hash(document_id) % number_of_nodes

Changing the number of nodes would require reassigning all the documents to the new nodes.

The algorithm guarantees that when a new node is added to the cluster, only a small number of documents will be moved to the new node.

Also, when a node is removed from the cluster, only a small number of documents will be moved to the remaining nodes, and they’ll be distributed evenly across the remaining nodes.

Let’s consider an example of node removal.

┌─────────────┐ ┌─────────────┐ ┌─────────────┐

│ Node A │ │ Node B │ │ Node C │

│ │ │ │ │ │

│ Documents: │ │ Documents: │ │ Documents: │

│ • doc_001 │ │ • doc_004 │ │ • doc_007 │

│ (shard A1) │ │ (shard B1) │ │ (shard C1) │

│ │ │ │ │ │

│ • doc_002 │ │ • doc_005 │ │ • doc_008 │

│ (shard A2) │ │ (shard B2) │ │ (shard C3) │

│ │ │ │ │ │

│ • doc_003 │ │ • doc_006 │ │ • doc_009 │

│ (shard A3) │ │ (shard B3) │ │ (shard C3) │

│ │ │ │ │ │

└──────┬──────┘ └──────┬──────┘ └──────┬──────┘

│ │ │

└──────────────────┼──────────────────┘

┌────────┴────────┐

│ Load balancer │

│ │

│ Routes based on │

│ consistent hash │

└─────────────────┘

The hash space looks like this: [A1] - [B1] - [A2] - [C1] - [B2] - [A3] - [C2] - [B3] - [C3]

When we remove Node B, the documents that were assigned to Node B will be moved to the remaining nodes, Node A and Node C.

Hash space after Node B removal: [A1] - [B1] - [A2] - [C1] - [B2] - [A3] - [C2] - [B3] - [C3]

The documents will be moved to the remaining nodes, A and C.

┌─────────────┐ ┌─────────────┐

│ Node A │ │ Node C │

│ │ │ │

│ Documents: │ │ Documents: │

│ • doc_001 │ │ • doc_007 │

│ (shard A1) │ │ (shard C1) │

│ │ │ │

│ • doc_002 │ │ • doc_008 │

│ (shard A2) │ │ (shard C3) │

│ │ │ │

│ • doc_003 │ │ • doc_009 │

│ (shard A3) │ │ (shard C3) │

│ │ │ │

│ + doc_004 │ │ + doc_006 │

│ (shard A2) │ │ (shard C3) │

│ │ │ │

│ + doc_005 │ │ │

│ (shard A3) │ │ │

│ │ │ │

└──────┬──────┘ └───────┬─────┘

│ │

└───────────┬───────────┘

┌─────────┴───────┐

│ Load balancer │

│ │

│ Routes based on │

│ consistent hash │

└─────────────────┘

Conclusion

Document Engine faced performance challenges due to file system cache limitations when handling large document collections. By implementing consistent hashing with virtual shards, we created a distributed caching system that:

  • Distributes documents evenly across multiple nodes
  • Minimizes data movement during cluster topology changes
  • Provides deterministic document-to-node mapping
  • Maintains high availability during node failures

This solution scales Document Engine’s caching capabilities horizontally while maintaining the simplicity of the original LRU cache design at each individual node.

Cache size dynamics for Document Engine with consistent hashing enabled

The graph above shows the cache size dynamics for the same Document Engine installation, but with consistent hashing enabled. Notice that with the same number of nodes and identical workload, the LRU cache cleanup now occurs approximately once every 1–2 hours, compared to roughly every 5 minutes in the previous implementation. Also note that this graph spans 10 hours, compared to the 5-hour timeframe shown in the earlier graph, further highlighting the dramatic improvement in cache efficiency.