Company
Date Published
Author
-
Word count
2172
Language
English
Hacker News points
None

Summary

Rollbar has been optimizing database performance by implementing caching strategies to reduce unnecessary load, focusing particularly on Python's SQLAlchemy v1.3 library. The blog highlights the challenges of caching, such as cache invalidation and potential security issues, and explains the chosen strategies: Cache Aside for reads and Write Around for writes. Serialization of cached data is done using Python's Pickle, despite its security risks, which are mitigated using a message authentication code. The post details creating a custom Query class in SQLAlchemy to intercept and cache queries and describes tests that validate the functionality, including handling detached instances and ensuring cached instances are bound to a session. It introduces the use of Mapper Options for injecting configurations and demonstrates how to decouple the caching logic from the caching client through a strategy pattern. The post concludes by promising a follow-up to discuss the application of these strategies within Rollbar's system.