Screenshot 2024 07 08 at 10.29.10 PM
109
Views

Initial Opening from Zerodha’s CTO

At the recent PGConference India 2023, attendees were treated to an in-depth account of Zerodha’s remarkable journey from its inception to becoming India’s largest stockbroker. Kailash Nadh, the CTO of Zerodha, shared the detailed story of how they built their tech infrastructure using open-source tools, particularly PostgreSQL, and how this foundation played a crucial role in their success. Here is a comprehensive recount of his insightful session.

Thank you for reading this post, don't forget to subscribe!

Kailash began his talk with a humble disclaimer about the lack of slides, choosing instead to focus on narrating the journey of Zerodha. Founded ten years ago, Zerodha has grown to become India’s largest stockbroker, boasting an impressive user base of over 11 million. Kailash’s recount was not just a technical discussion but a narrative of innovation, persistence, and strategic planning.

Kailash Nadh CTO of Zerodha at PostgresSQL DB
PC: PGconf India 2023

Early Days and Initial Challenges

In the early days, the idea of building a tech team at Zerodha was driven by a clear vision to revolutionize the financial services industry in India. Back in 2013, the financial services sector was devoid of quality consumer products, making it a ripe field for innovation. Kailash, a developer and hobbyist, saw this as a golden opportunity to experiment and create new solutions.

Initially, the tech team’s trajectory was undefined. Kailash would sit with different departments—support, compliance, and others—to understand their manual processes. He then wrote Python scripts to automate these tasks, drastically reducing the time required to complete them. This approach of understanding the core problems and automating solutions laid the foundation for Zerodha’s technological journey.

In late 2013, they set up their first self-hosted database, PostgreSQL 9.3, marking the true beginning of their financial technology infrastructure. This move was a bet on the potential of PostgreSQL, which at that time was still seen by many as an experimental database not fit for prime time. This bet, however, paid off beautifully.

Technology-Driven Approach

Kailash emphasized the importance of self-hosting and mastering technology internally. Zerodha’s approach was to build everything from the ground up, using barebones infrastructure, installing necessary technologies, studying them, growing, and scaling them without external help. This philosophy of self-reliance and mastery was pivotal in their development.

From 2013 onwards, Zerodha used open-source technologies like PostgreSQL and Python scripts to build their systems. Today, they run large-scale databases with tens of terabytes of data, managing hundreds of billions of financial records. They install, maintain, and run these databases themselves, showcasing their deep understanding and control over their technology stack.

Growth and Scalability

Zerodha’s user base grew exponentially from 5,000 to over 11 million users. They handle massive real-time traffic, with over 2 million users logging in within seconds when the stock markets open. Technologies like Redis and PostgreSQL have been integral in managing this scale with minimal manual intervention.

Kailash shared that their infrastructure scaled efficiently over the years without significant changes, highlighting the robustness of their technological decisions. They have Redis instances that have been running for four to five years with zero maintenance and databases that serve hundreds of thousands of requests every second with practically zero manual intervention. This did not happen overnight; it was a result of careful planning and execution over the last decade.

Infrastructure and Cost Management

One of the key points Kailash made was about their philosophy of minimal external dependencies. Zerodha self-hosts almost all its systems, using AWS for infrastructure but not relying on managed services for databases. This approach has resulted in significant cost savings. They spend virtually nothing on external IT vendors or SaaS subscriptions, which is remarkable for handling millions of clients and hundreds of millions of support tickets.

Kailash illustrated this with the example of their support ticketing system. Implemented in 2014, the system has handled millions of support tickets with minimal costs. The same PHP-based system is still in use today, running on an EC2 instance that costs peanuts. The amount of money they spend on the technical infrastructure to handle millions of clients and hundreds of millions of support tickets over many years is practically zero.

Key Systems and Innovations

Support Ticketing System

In the early days, Zerodha used a Gmail inbox for their support ticketing system, which worked for a small number of clients. As they grew, this system became inadequate. Kailash recalled using O’s Tickets, a PHP-based system he had played around with in 2005 or 2006. They installed and set it up in 2014, and this same instance is running today, handling millions of support tickets from thousands of employees daily. The system requires virtually no maintenance and runs on minimal costs, highlighting the efficiency and longevity of their chosen technologies.

HR Management

As Zerodha’s employee count grew, managing HR functions became challenging. In 2016, they adopted ERPNext for employee management, integrating it deeply into their operations. This system handles everything from payroll to leave requests and is also self-hosted and self-managed by the tech team. Kailash emphasized that managing internal systems efficiently is as critical as managing consumer-facing products.

Trading Platform (Kite)

Zerodha never initially planned to build a trading platform. However, by 2015, it became clear that to offer meaningful financial services, they needed to provide well-designed consumer technology. This realization led to the creation of Kite, their investment platform. Kite defined Zerodha’s journey in the financial technology space, offering a seamless and efficient trading experience to millions of users.

Infrastructure and Technology Choices

Kailash discussed the various technologies Zerodha experimented with and adopted over the years. Initially, they built systems in Python but soon hit performance bottlenecks. This led them to switch to Go around late 2014 or 2015. Go became a primary component of their stack, particularly for high concurrency, high traffic systems. Most requests on the Kite trading platform finish in less than 50 milliseconds, thanks to the efficiency of Go and their well-optimized database systems.

Challenges and Adaptations

Kailash shared how the COVID-19 pandemic in 2020 posed a significant challenge. Zerodha experienced a 5x increase in orders within weeks, going from handling 2 million orders a day in January 2020 to 12 million orders a day by mid-2020. Despite this sudden surge, their infrastructure scaled efficiently without major changes. This showcased the robustness of their technological decisions and their ability to handle unexpected growth.

Philosophy and Approach

The cornerstone of Zerodha’s approach is simplicity and mastery of technology. Kailash stressed the importance of understanding and controlling their tech stack, avoiding black boxes and complex abstractions. This philosophy has paid off, especially during unexpected events like the pandemic. Zerodha’s success is built on common-sense decisions, minimal reliance on external vendors, and a focus on mastering their systems.

Industry Impact and Future Directions

Zerodha’s success has become a talking point in the industry. Other financial institutions are adopting similar open-source, self-hosted approaches to reduce dependencies and licensing costs. Regulatory changes are also pushing companies towards greater technological ownership, making Zerodha’s approach increasingly relevant.

Kailash mentioned that large financial institutions are now looking at migrating away from expensive licensing and external dependencies. They are setting up tech teams to manage open-source systems in-house. This shift is not just a trend but a necessity in the evolving regulatory landscape. Institutions are realizing the importance of owning and understanding their tech stacks to remain competitive and compliant.

Conclusion

Kailash concluded by highlighting that Zerodha’s success is due to its common-sense approach to technology, minimal reliance on external vendors, and a focus on mastering their systems. This strategy has resulted in high efficiency, cost savings, and the ability to handle massive scale with a relatively small tech team.

Questions and Insights

During the Q&A session, Kailash addressed several interesting questions from the audience:

Regulatory Compliance

Question: How do you handle situations where regulatory requirements change suddenly, requiring immediate compliance?

Kailash’s Answer: In the financial industry, regulatory compliance is paramount. All our business plans are secondary to regulatory requirements. If SEBI (Securities and Exchange Board of India) mandates a change, we pause everything to comply with the new requirements. This agility is possible because we have complete control over our infrastructure and tech stack. Self-hosting allows us to make necessary changes quickly without relying on external vendors.

Modernizing Tech Stacks

Question: What is your take on modernizing tech stacks for financial companies, especially in a heavily regulated market?

Kailash’s Answer: Modernizing tech stacks should be evaluated on a case-by-case basis. Each organization has unique challenges and a distinct culture. There is no one-size-fits-all solution. We must objectively assess our needs and choose technologies that best fit our requirements. For Zerodha, adopting open-source technologies and self-hosting has worked well, but other organizations might find different solutions more suitable.

High Availability and Risk Management

Question: How do you ensure high availability and manage risks, especially when some of your systems have been running for years without updates?

Kailash’s Answer: Risk management is a gradient. Some systems, if well-isolated, can run for years without updates. For example, we have Redis instances that have been running for four to five years with zero maintenance. However, systems that face higher risks or are more critical require regular updates and maintenance. The key is to understand the specific context and criticality of each system and manage them accordingly.

Vendor Dependency and External Help

Question: Why does Zerodha avoid relying on external vendors and managed services, and how do you handle the potential challenges this might bring?

Kailash’s Answer: We avoid external vendors and managed services to maintain complete control over our infrastructure and to minimize costs. This approach requires us to master the technologies we use and handle everything in-house

Also Read: How Zerodha, India’s Largest Stock Broker, Tuned PostgreSQL for Big Data Management

Article Categories:
How To · Softwares · Technology

Comments are closed.