Hasty Briefsbeta

Bilingual

Canva uses S3 for logged-in session management

10 hours ago
  • Canva uses encrypted browser cookies to store user session details, enabling fast authentication without per-request database lookups.
  • Session revocations (e.g., after logout or permission changes) are stored in an in-memory cache for near real-time updates and reliability.
  • At scale, seeding the in-memory cache during deployments caused a stampede on MySQL, requiring a more scalable solution.
  • The solution replaces the direct database load with S3 object storage, partitioning revocations into 30-minute chunks stored as compact sorted binary arrays.
  • Each gateway downloads only the relevant recent S3 chunks on startup and uses binary search for fast revocation checks, reducing memory footprint by 87.5%.
  • An asynchronous worker process updates the S3 chunks by scanning the database and using conditional PUT requests to avoid lost updates and ensure consistency.
  • The system improved deployment speed, reduced the need for MySQL read replicas, and scaled predictably with write throughput and site traffic.