SlideShare a Scribd company logo
PAIN-FREE PIPELINING
John Loehrer
Joya Communications
efficient Redis network i/o
PAIN-FREE PIPELINING
WHAT IS PIPELINING?
• Client: INCR X
• Server: 1
• Client: INCR X
• Server: 2
• Client: INCR X
• Server: 3
• Client: INCR X
• Client: INCR X
• Client: INCR X
• Server: 1
• Server: 2
• Server: 3
SINGLE VS. PIPELINE
WHY PIPELINE?
RTT
COMPARE THROUGHPUT
Single commands vs Pipelined
• single: 17k req/s
• pipelined: 260k req/s
QUICK BENCHMARK
redis-benchmark -t get -c 1
SO WHAT?
fast enough without pipelining
LOOPBACK != PROD
need to simulate real network conditions
TOXIPROXY THROTTLING
https://github.com/Shopify/toxiproxy
CONFIGURE TOXIPROXY
• toxiproxy-cli create redis -l localhost:26379 -u localhost:6379
• toxiproxy-cli toxic add redis -t latency -a latency=1
• single: 216 req/s
• pipelined: 4300 req/s
NETWORK BENCHMARK
1 ms throttle
0 15 30 45 60
localhost
productio
n
CPU Network
LOW-HANGING FRUIT
Optimize CPU or Network?
OPTIMIZE RTT
mitigate cost of network round-trips
PIPELINES FTW!
BUT …
PREPARE FOR THE PAIN
GIVE UP ENCAPSULATION?
REFACTORING HURTS
pipelining api is different from single calls
WHY NOT ASYNC?
• one connection for each command
• requires different programming approach
ASYNC I/O ISSUES
MY PARADIGM SHIFT
pipeline everything
RedisConf17 - Pain-free Pipelining
LEARN FROM MY MISERY
After years of effort …
Reference Implementation
redpipe.readthedocs.io
FAMILIAR API
RedPipe works almost like redis-py
HOW IS IT DIFFERENT?
• redis-py pipelines make you wait till
payday
• RedPipe gives you instant credit
REDPIPE RETURNS FUTURES
WHAT’S THE POINT?
Code Reuse & Flexibility
• assign data before you have it
• return the response before it has been
calculated
• allows logical encapsulation even while
pipelining
FUTURES WRAP RESPONSES
Use them like the real thing
If it quacks …
DUCK TYPING
USE CALLBACKS TO BUILD
YOUR OWN FUTURES
NESTED PIPELINES
WRAP NOTHING
instantly executes
WRAP ANOTHER PIPE
passes the commands upstream
WHAT ELSE?
RedPipe has some other fun things …
KEYSPACES
still works like redis-py
DEFINE YOUR DATA TYPE
• strings
• lists
• sets
• hashes
• sorted sets
• hyperloglog
• geo (in progress)
SPECIFY A CONNECTION
can talk to multiple backends transparently
CHARACTER ENCODING
translate fields to a consistent data-type
SUPPORT COMPLEX
TYPES
hash fields support python primitives
• bool
• int
• float
• list
• dict
WRITE YOUR OWN
fields just need an encode/decode method
STRUCTS
ability to manipulate redis like a dictionary …
And still pipeline it all
QUESTIONS?

More Related Content

PPTX
RedisConf17 - Roblox - How Roblox Keeps Millions of Users Up to Date with Red...
PDF
Back your App with MySQL & Redis, the Cloud Foundry Way- Kenny Bastani, Pivotal
PPTX
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
PPTX
RedisConf17 - Redis Enterprise: Continuous Availability, Unlimited Scaling, S...
PPTX
Walmart & IBM Revisit the Linear Road Benchmark- Roger Rea, IBM
PPTX
What's new with enterprise Redis - Leena Joshi, Redis Labs
PDF
Gwen Shapira, Confluent | Kafka Summit 2020 Keynote | Kafka’s New Architecture
PDF
HIgh Performance Redis- Tague Griffith, GoPro
RedisConf17 - Roblox - How Roblox Keeps Millions of Users Up to Date with Red...
Back your App with MySQL & Redis, the Cloud Foundry Way- Kenny Bastani, Pivotal
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
RedisConf17 - Redis Enterprise: Continuous Availability, Unlimited Scaling, S...
Walmart & IBM Revisit the Linear Road Benchmark- Roger Rea, IBM
What's new with enterprise Redis - Leena Joshi, Redis Labs
Gwen Shapira, Confluent | Kafka Summit 2020 Keynote | Kafka’s New Architecture
HIgh Performance Redis- Tague Griffith, GoPro

What's hot (20)

PPTX
RedisConf18 - Redis Fault Injection
PDF
Spark Compute as a Service at Paypal with Prabhu Kasinathan
PDF
RedisConf18 - Redis at LINE - 25 Billion Messages Per Day
PDF
Scalable and Reliable Logging at Pinterest
PDF
Should you read Kafka as a stream or in batch? Should you even care? | Ido Na...
PDF
Stream processing with Apache Flink @ OfferUp
PPTX
RedisConf17 - Operationalizing Redis at Scale
PPTX
RedisConf17 - Redis Development, An Update - @antirez
PDF
RedisConf18 - Redis on Flash
PDF
Redis in a Multi Tenant Environment–High Availability, Monitoring & Much More!
PPTX
Robust Stream Processing with Apache Flink
PDF
Building Microservices with Apache Kafka by Colin McCabe
PDF
Apache Flink @ Alibaba - Seattle Apache Flink Meetup
PDF
Hadoop summit - Scaling Uber’s Real-Time Infra for Trillion Events per Day
PDF
Bitsy graph database
PPTX
RedisConf18 - Implementing a New Data Structure for Redis
PPTX
Vitalii Korzh - "Exciting Migrations"
PPTX
RedisConf18 - Redis Enterprise on Cloud Native Platforms
PDF
Escalando Foursquare basado en Checkins y Recomendaciones
PDF
Improving Logging Ingestion Quality At Pinterest: Fighting Data Corruption An...
RedisConf18 - Redis Fault Injection
Spark Compute as a Service at Paypal with Prabhu Kasinathan
RedisConf18 - Redis at LINE - 25 Billion Messages Per Day
Scalable and Reliable Logging at Pinterest
Should you read Kafka as a stream or in batch? Should you even care? | Ido Na...
Stream processing with Apache Flink @ OfferUp
RedisConf17 - Operationalizing Redis at Scale
RedisConf17 - Redis Development, An Update - @antirez
RedisConf18 - Redis on Flash
Redis in a Multi Tenant Environment–High Availability, Monitoring & Much More!
Robust Stream Processing with Apache Flink
Building Microservices with Apache Kafka by Colin McCabe
Apache Flink @ Alibaba - Seattle Apache Flink Meetup
Hadoop summit - Scaling Uber’s Real-Time Infra for Trillion Events per Day
Bitsy graph database
RedisConf18 - Implementing a New Data Structure for Redis
Vitalii Korzh - "Exciting Migrations"
RedisConf18 - Redis Enterprise on Cloud Native Platforms
Escalando Foursquare basado en Checkins y Recomendaciones
Improving Logging Ingestion Quality At Pinterest: Fighting Data Corruption An...
Ad

Similar to RedisConf17 - Pain-free Pipelining (20)

PPT
Python redis talk
PDF
RedisConf18 - Writing modular & encapsulated Redis code
PPT
Redis And python at pycon_2011
PDF
PDF
Python in the land of serverless
PPT
Dev8d 2011-pipe2 py
PDF
Scaling Redis To 1M Ops/Sec: Jane Paek
PDF
Redis 101
PPTX
Write a redis client of your own
PDF
Introduction to redis - version 2
PDF
Redis Everywhere - Sunshine PHP
PDF
Speed up your Symfony2 application and build awesome features with Redis
PDF
PHP projects beyond the LAMP stack
PDF
Introduction to Redis
PDF
Tuga IT 2017 - Redis
PDF
Redis - Usability and Use Cases
PDF
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
PDF
A Brief Introduction to Redis
PDF
Redis everywhere - PHP London
PDF
Atomicity In Redis: Thomas Hunter
Python redis talk
RedisConf18 - Writing modular & encapsulated Redis code
Redis And python at pycon_2011
Python in the land of serverless
Dev8d 2011-pipe2 py
Scaling Redis To 1M Ops/Sec: Jane Paek
Redis 101
Write a redis client of your own
Introduction to redis - version 2
Redis Everywhere - Sunshine PHP
Speed up your Symfony2 application and build awesome features with Redis
PHP projects beyond the LAMP stack
Introduction to Redis
Tuga IT 2017 - Redis
Redis - Usability and Use Cases
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
A Brief Introduction to Redis
Redis everywhere - PHP London
Atomicity In Redis: Thomas Hunter
Ad

More from Redis Labs (20)

PPTX
Redis Day Bangalore 2020 - Session state caching with redis
PPTX
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
PPTX
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
PPTX
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
PPTX
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
PPTX
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
PPTX
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
PPTX
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
PPTX
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
PPTX
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
PPTX
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
PPTX
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
PPTX
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
PPTX
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
PPTX
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
PPTX
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
PPTX
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
PDF
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
PPTX
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
PPTX
Redis as a High Scale Swiss Army Knife by Rahul Dagar and Abhishek Gupta of G...
Redis Day Bangalore 2020 - Session state caching with redis
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Redis as a High Scale Swiss Army Knife by Rahul Dagar and Abhishek Gupta of G...

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Electronic commerce courselecture one. Pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation theory and applications.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Machine learning based COVID-19 study performance prediction
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Electronic commerce courselecture one. Pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Network Security Unit 5.pdf for BCA BBA.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation theory and applications.pdf
The AUB Centre for AI in Media Proposal.docx
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Mobile App Security Testing_ A Comprehensive Guide.pdf
Spectral efficient network and resource selection model in 5G networks
Machine learning based COVID-19 study performance prediction
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Monthly Chronicles - July 2025
Reach Out and Touch Someone: Haptics and Empathic Computing

RedisConf17 - Pain-free Pipelining

Editor's Notes

  • #3: We built our code so that any function can be pipelined with another. Took a lot of trial and error to realize we could do that and find efficient patterns to do so. Hindsight is 20/20.
  • #4: the pic is of keystone XL pipeline. Also think of HTTP pipelining. Also called boxcarring.
  • #6: Total API request time is often a function of number of network round trips * network latency. Tell story of fighting fire behind my house as a kid, with burlap sacks. Most people think about transaction support but I’ve always found LUA scripting a much better way to accomplish this. Pipelining is about improving network efficiency. You could try to do it with LUA, but then you can’t chain together smaller bits of logic together flexibly.
  • #8: unscientific, but you can test it in your own environment
  • #9: it all depends on what proportion of an api call is spent waiting on redis responses We use redis and found that a big chunk of time was spent talking to redis.
  • #14: Made up numbers, but illustrates a point. On localhost I profile my app and find that a particular API call takes 6ms, and 1ms is spent making calls to redis. So I think I should spend my time optimizing CPU. Maybe I should rewrite my python app in Go (actually, maybe I should, but that’s a different talk). But if you profile a production environment, you see that network is actually a much bigger slice of the pie. Now I still spend 5ms on computation in python, but I spend 50ms talking to redis. Network is clearly the more fertile ground for optimization.
  • #24: Tell story of the gate in west texas.
  • #26: rewrite of all the ideas I’ve learned so far. What I would have written 3 years ago if I knew what I know now.
  • #42: once you know the data type, you can make assumptions about the data going in and out of redis. Before that, you have to assume it’s all bytes.