Migrating from Node Redis to Ioredis: a slightly bumpy but faster road
The blog post discusses the migration from Node Redis client library to Ioredis for Ably's backend code written in Node.js. Redis is a distributed, in-memory database used by Ably for short-term storage of various entities such as authentication tokens and ephemeral channel state. They initially chose Node Redis due to its official recommendation and long history but faced performance issues. Upon investigation, they discovered that if one argument to the Redis command is a buffer, Node Redis performs three separate socket writes per argument every time, leading to excessive CPU usage for their use case. This motivated them to look for alternatives, eventually choosing Ioredis due to its efficient handling of buffers and promising performance results in tests. The migration process involved replacing functions and parameters using the Ioredis guide on migrating from node_redis, addressing API differences between Node Redis and Ioredis, and resolving bugs found during testing. Load testing showed a 30% reduction in CPU usage after switching to Ioredis, confirming its performance benefits for Ably's use case.
Company
Ably
Date published
Aug. 17, 2021
Author(s)
Jonathan Mercier-Ganady
Word count
1750
Hacker News points
1
Language
English