Zerodha CTO Shares Patterns for Scaling Postgres

Zerodha's CTO shared techniques for scaling their database to over 7 million Postgres tables. Key patterns include using async queues, DB-agnostic middleware written in Go, and creating separate databases for results—offering a practical playbook for managing technical debt during rapid growth.

Zerodha's scaling challenge stems from being India's largest retail stockbroker, processing 15-20% of the country's daily trades and serving over 9 million active users with a lean engineering team of about 33. The primary bottleneck was not transactions, but the massive concurrency of users generating complex, historical financial reports, which could overload their primary databases. The "7 million tables" are not in a single database instance, which would be unmanageable. Instead, when a user requests a heavy report, Zerodha spins up an ephemeral, isolated Postgres container that loads only that user's relevant data partitions—creating a temporary, dedicated database that is destroyed after the report is generated. This prevents slow, resource-intensive queries from impacting the core transactional systems. This approach is a deliberate strategy for managing technical debt, which unmanaged, can cripple velocity in a growing startup. High-performing engineering teams often formalize this by allocating a dedicated "debt budget," typically 15-25% of each sprint, to refactoring and stability work, ensuring the codebase can evolve at the market's pace. The orchestration of ephemeral databases mirrors challenges in coordinating multi-agent AI systems. Open-source frameworks like CrewAI and Microsoft's AutoGen are gaining traction for this, providing structured ways to manage role-based agents, task delegation, and collaborative workflows without having to build the entire foundation from scratch. For consumer-facing products, the user experience of complex agentic behavior is critical. Emerging UX patterns are moving beyond simple chatbots toward embedded AI, where agent actions are integrated into the core interface, and "intent-driven shortcuts" that anticipate user needs to make the AI feel like a helpful, proactive assistant rather than a separate tool. In Beijing, the AI agent ecosystem is rapidly evolving, with major players like Tencent, Baidu, and Ant Group offering platforms for agent development. A key trend is the deep integration of AI agents into existing super-apps for "agentic commerce," enabling users to complete entire transaction cycles, from discovery to payment, within a single conversational interface. Recent research in AI agent architecture focuses on enabling more autonomous, long-running tasks. Key areas that could translate to product improvements include agentic memory for managing long-term and short-term context, self-correction mechanisms for error handling, and more sophisticated planning and tool-use capabilities. China's regulatory landscape for AI is also solidifying. Amendments to the Cybersecurity Law, effective January 2026, formally incorporate AI governance. Companies must navigate rules around generative AI services, deep synthesis, and mandatory labeling for AI-generated content, reflecting a government focus on balancing innovation with control.

Get your own daily briefing

Scout delivers personalized news, insights, and conversations tailored to your role and industry.

Download on the App Store

Shared from Scout - Be the smartest in the room.