Definition
What it is
A buffer absorbs differences in throughput. A network card delivers packets at 10 Gbit/s; the application reads them at 500 Mbit/s. Without a buffer, most packets would be dropped. With a buffer, they queue in kernel memory, and the application drains them at its own pace.
Buffers exist in every layer: CPU caches, disk controllers, network sockets (SO_RCVBUF, SO_SNDBUF), keyboard input, audio output, video streaming, HTTP response bodies. A buffer is different from a cache: a cache holds data for reuse; a buffer holds data for transfer.
Why it matters
Buffers convert backpressure into latency. If a producer is faster than a consumer, either the producer waits (blocking) or the excess is stored (buffering). Buffers prefer latency: the data waits, not the producer. That trade-off is what makes networks and IO work at heterogeneous speeds.
Buffer vs cache vs queue
Aspect | Buffer | Cache | Queue |
|---|---|---|---|
Purpose | Smooth flow | Store for reuse | Decouple producer/consumer |
Who reads | One consumer | Many readers | Workers |
Eviction | Drained | LRU/TTL | Ack-based |
Lifetime | Milliseconds | Minutes/hours | Until processed |
Example | Socket buffer | SQS |
Producer and consumer
graph LR P[Producer fast] -->|write| B[Buffer] B -->|read| C[Consumer slow] B -.->|full| Block[Block producer] B -.->|empty| Wait[Consumer waits] style B fill:#E8F5E9
Buffer strategies
Buffers that behave
Size for the worst burst
A 1 KB buffer for a 10 Gbit/s network drops packets. Size to the peak, not the average.
Ring buffers for bounded memory
A fixed-size circular buffer never grows: when full, oldest data is overwritten or the producer blocks.
Monitor fill level
A buffer at 90% is a buffer that will overflow soon. Alert before it does.
Flush on shutdown
A buffer that loses its data on shutdown is a data-loss bug waiting for a disk fill.
Bounded is safer than unbounded
An unbounded buffer is a memory leak that grows on backpressure.
Common failures
Origin
The word comes from Old French buffe, "a blow", and entered English in the 19th century as a mechanical device that absorbs shocks (railway buffers, buffer springs). Computing adopted it in the 1950s, when IBM mainframes used "buffers" to decouple tape reads from CPU speed. The metaphor is exact: a buffer absorbs the shock of speed mismatch.
A buffer is a region of memory used to temporarily hold data while it is being moved from one place to another.
— IEEE Std 610.12-1990, *Glossary of Software Engineering Terminology*
Evidence
FAQ
- Buffer vs cache?
A cache stores for reuse; a buffer stores for transfer. A cache is read many times; a buffer is written and read once.
- When does a buffer add latency?
Always. The question is whether the latency is worth the throughput. Small buffers = low latency, low throughput. Large buffers = high throughput, high latency.
- How to pick a size?
Measure the burst. The buffer must absorb the worst spike without dropping, at the cost of the peak latency that the buffer introduces.
- Bounded vs unbounded?
Bounded always, unless you like OOM kills. Bound it, and decide what to do when full: block, drop, or spill to disk.
Connections
- cache
- queue
- backpressure
- ring-buffer
- latency
IEEE Std 610.12-1990. Glossary of Software Engineering Terminology. https://standards.ieee.org/ieee/610.12/5456/
Linux man-pages (2024). socket(7) — SO_RCVBUF, SO_SNDBUF. https://man7.org/linux/man-pages/man7/socket.7.html
Etymology
Origin: borrowed
buffer(noun): from Old French buffe, "a blow"; mechanical sense (railway buffer) from 19th century
Semantic network
● broader ● narrower ● related
Used in the garden
- 10 Secret Web Applications Gurus Don't Want You to Know: Limited Budget Entrepreneurs Edition (5×)
- Stremio + Torrentio: The Ultimate Free Streaming Setup (5×)
- Unlock Your Potential Now! 10 FREE Web Apps Every Savvy Entrepreneur MUST Know to Multiply Impact & Profits (5×)
- 10 Web Gems NO ONE Told You About to Dominate Your Online Business for FREE! Solo Creators & Entrepreneurs Edition (4×)
- 10 Secret (and Free) Web Applications for Digital Entrepreneurs and Content Creators That Will Transform Your Business (4×)
- Unlock Growth: 10 Free Web Apps Every Ambitious Entrepreneur MUST Know to Scale Rapidly (4×)
- 10 FREE Web Apps EVERY Content Creator and Entrepreneur MUST KNOW (The PROS' Secret!) (4×)
- Unlock Your Potential! 10 Secret Web Apps That Will Transform Your Day (Entrepreneurs & Content Creators Edition) (4×)
- Unlock Digital Success! 10 Secret Web Gems for Budget-Conscious Entrepreneurs (4×)
- 10 FREE Web Apps That Will Skyrocket Your Digital Marketing (Without Spending a Dime!) (3×)
- The Micro-Business Owner's Guide to Cash Flow Management (3×)
- The Savvy Entrepreneur's Secret: 10 FREE Web Apps That Will Skyrocket Your Digital Business (2×)
- 10 Secret Web Apps That Will Unleash Your Entrepreneurial Potential (Free or Nearly So!) (2×)
- The Secret Arsenal for Creators! 10 FREE Web Apps That Will Skyrocket Your Digital Success (Creators & Entrepreneurs Edition) (2×)
- The Secret to Vibrant Longevity: Defy the Clock with These Game-Changing Tricks! (1×)
- Cash Flow Forecasting: How to Predict Your Business's Next 3 Months (1×)
- Content Distribution Strategies: How to Maximize Reach and Impact (1×)
- The DBA-Free Playbook: Unlocking MySQL's Hidden Power for Your SaaS (1×)
- Automate to Liberation: The 5‑Tool Stack That Runs Your Business (1×)
- Beyond K MRR: Dominating Your Niche with Lean Scaling in LatAm (1×)
- Unlock Success! 10 FREE Web Apps Your Competitors DON'T Want You To Know About (Smart Entrepreneur Edition) (1×)
- The Silent Engine: Automating Acquisition for Bootstrapped Micro-SaaS (1×)
- The Hidden Secret to Multiply Your Digital Wealth: Repeat and Continue (1×)
- Financial Forecasting: How to Predict Your Next 12 Months (1×)
- The Growth Blindness: Why Your Business Is Stuck (And How Cash Visibility Unlocks It) (1×)
- The Secret to Profitable Digital Businesses: Repeat and Continue (1×)
- The 'Unfair' Pricing Model That Doubles Your Profits Without Losing Customers (1×)
- The Secret to Profitable Digital Businesses: Repeat & Scale (1×)
- The Monotributo Trap: How Argentine Freelancers Are Overpaying (And How to Stop) (1×)
- Unlocking Hyper-Growth: The Bootstrapper's Blueprint for SaaS B2B in Mexico (1×)
- The Brand Protection Strategy (1×)
- Social Media Content Strategy: The Complete Guide (1×)
- From Script to Microservice: Scaling Reporting Automation to 10K Daily Requests (1×)
- The Power of Micro-Automations for Service-Based Businesses (1×)
- The Secret to Digital Businesses That Never Stop Generating Profits (1×)
- Content Repurposing: How to Maximize the Value of Every Piece You Create (1×)
- 10 Secret Web Apps That Will Skyrocket Your Success Without a Penny (Zero-Budget Entrepreneur Edition) (1×)
- The Hidden Secret to Entrepreneurship & Multiplying Your Money: Revealed! (1×)
- The Cash Flow Crisis: Why 82% of Small Businesses Fail (1×)
- The Food & Beverage Founder's Guide to Supply Chain Resilience (1×)
- The K Blueprint (1×)
- Social Media Marketing and Email Marketing: The Complete Guide (1×)
- 3D Printing Pet Products: The Micro-Manufacturing Goldmine (1×)
- The Brand Secret Gurus Hide: Repeat Success Endlessly! (1×)
Sources
IEEE Std 610.12-1990. Glossary of Software Engineering Terminology. https://standards.ieee.org/ieee/610.12/5456/
Linux man-pages (2024). socket(7). https://man7.org/linux/man-pages/man7/socket.7.html