Zerodha Architecture Explained: How India's Largest Broker Self-Hosts Its Stack
Short answer: Zerodha self-hosts almost everything using free and open-source software. Its systems run in a hybrid setup: physical racks in two data centres where stock exchange leased lines end, plus AWS (2020). Services are written mainly in Go and Python. Data lives in self-managed PostgreSQL on bare EC2 instances (about 20 TB across four shards in 2021), logs in ClickHouse (2023), and metrics in Prometheus and VictoriaMetrics.
Suppose you buy shares on Zerodha Kite
It is 9:20 am. You buy 10 shares on Kite from Pune. In simple terms:
- Kite (built with Flutter on mobile) sends your order to Zerodha's in-house systems.
- Order systems run near the exchange leased lines in Zerodha's data centres, so orders reach NSE or BSE quickly.
- Services written in Go check rules and margins.
- After the market closes, end-of-day jobs load exchange files into large PostgreSQL databases for Console (P&L, ledger, reports).
- That night, a self-hosted pipeline on EC2 and S3 generates, digitally signs and emails 1.5+ million contract note PDFs in about 25 minutes (2024).
- All logs go to ClickHouse; metrics to VictoriaMetrics.
What architecture style does Zerodha use?
Zerodha is famous for a tiny tech team (about 30 people in 2020) and a "simple scales" philosophy.
- Self-host FOSS: Zerodha's stack page lists self-hosted tools: Go, Python, Java, Dart; PostgreSQL, ClickHouse, Redis, ScyllaDB, MySQL; Nginx, HAProxy, Kong; NATS, Kafka; Nomad, Salt, GitLab.
- Scale the application before the infrastructure (2020): keep networking and IO minimal, and prefer simple designs.
- Hybrid hosting: two data centres plus AWS, bare metal to Kubernetes clusters.
- Batch work on raw EC2: short-lived EC2 instances and S3 for big jobs like contract notes, instead of managed services.
Zerodha architecture diagram (public parts)
This diagram shows only what Zerodha or its partners have shared publicly. Press Play to follow a request step by step.
- You place a buy order on Kite.
- Self-hosted proxies route it.
- Go services check and send the order.
- Reports come from large PostgreSQL databases.
- Hot data is cached in Redis.
- Events move through Kafka and NATS.
- Prometheus and VictoriaMetrics watch everything.
- Contract notes are made on EC2 and stored in S3.
- Your order is filled.
What does Zerodha use? Main technologies
| Layer | What Zerodha uses (public) | What it does in simple words |
|---|---|---|
| Hosting | Two data centres + AWS | Hybrid setup |
| Languages | Go, Python, Java, Dart | Services and apps |
| Mobile | Flutter | Kite app |
| Database | PostgreSQL (self-hosted on EC2) | Trades, P&L, ledger |
| Logs | ClickHouse + Vector (2023) | Log storage and search |
| Queues | Kafka, NATS | Messaging |
| Monitoring | Prometheus, VictoriaMetrics, Grafana | Metrics and alerts |
| Orchestration | Nomad, Salt, Kubernetes | Deploy and manage |
Which cloud provider does Zerodha use?
Zerodha uses a hybrid setup: physical racks in two data centres (where exchange leased lines end) and AWS. On AWS it mostly uses raw EC2 instances, EBS snapshots and S3, and runs its own software on them rather than using many managed services.
How does Zerodha send 1.5 million contract notes in 25 minutes?
Every trading day, SEBI rules require brokers to send each client a digitally signed contract note before the next trading day. Since 2024 Zerodha uses a self-hosted pipeline:
- Each note passes through four kinds of workers: process data, generate the PDF (from Typst markup), digitally sign it, and email it.
- Work is split into jobs that run on many short-lived EC2 instances, started only for the duration of the work.
- Workers read input files from S3, process them and write the output back to S3 for the next worker.
- Zerodha compared EBS, EFS and S3 for this shared storage and picked S3 for cost and simplicity; AWS also suggested FSx for Lustre.
- Its earlier self-hosted Postal mail server became a bottleneck as volume grew, which was one reason to redesign.
The result: more than 1.5 million PDFs generated, signed and emailed in about 25 minutes at negligible cost, and the same orchestration ideas now power other distributed jobs. It is a good example of Zerodha's rule: scale the application design before throwing infrastructure at a problem.
How it started: a 30-person team builds India's largest broker (2013 to 2020)
- Zerodha was founded in 2010; its tech team started around 2013.
- By 2020 a team of about 30 had built the trading platform, back office and reporting in-house; Zerodha handled about 15% of daily retail trading volume in India.
- In 2018 Zerodha bet on Flutter for its mobile apps while Flutter was still in alpha, after trying native and React Native.
- Logs ran on the ELK stack from 2018 until traffic grew sharply after 2020, which led to the ClickHouse move.
How does Zerodha store data?
- PostgreSQL: hundreds of billions of rows, about 20 TB across four shards (2021); a separate Postgres instance acts as a hot cache; up to 40,000 to 50,000 queries per second at peak.
- AWS disk snapshots for backups; failover replicas for availability.
- ClickHouse for logs, some kept long-term for regulators.
- S3 for temporary files in batch jobs.
How does Zerodha monitor its systems?
- Prometheus with Grafana, and VictoriaMetrics for long-term storage, across both data centres and AWS (2020).
- Monitors system, application and business metrics.
- ClickHouse + Vector for logs; Alertmanager and Sentry are on the stack page.
If we built an app like Zerodha on AWS (illustrative)
Please read this first
This section is a learning design by Ravindra Bagale. It is not Zerodha's real setup. Zerodha uses AWS together with its own data centre racks. We use AWS here because it is what you learn in the AWS course.
Suppose you want to build "NiveshKaro", a simple investing app for mutual funds. Here is a simple AWS layout. A real broker must also connect to exchanges and follow SEBI rules.
1. Network: VPC, subnets, route tables, gateways
- Create one VPC with CIDR
10.0.0.0/16in the Mumbai region (ap-south-1). - Use two Availability Zones (A and B), so one AZ failing does not stop the app.
- In each AZ make three subnets: public (load balancer, NAT gateway), private app (your code) and private data (databases, cache).
- Attach one internet gateway (IGW) to the VPC. Public route table:
0.0.0.0/0 → IGW. This route is what makes a subnet public. - Private app route table:
0.0.0.0/0 → NAT gateway, so servers can download updates but nobody can connect in from the internet. - Private data route table: only the local VPC route. Use VPC endpoints to reach S3, DynamoDB and SQS without going over the internet.
2. Compute: where the code runs
- ALB in public subnets.
- Go services on EKS.
- Night batch jobs read SQS on Spot instances.
3. Storage and databases
- Aurora PostgreSQL for the ledger.
- DynamoDB for order history.
- ElastiCache for quotes; S3 for contract notes.
4. Monitoring
- Amazon Managed Prometheus + Grafana.
- CloudWatch Logs or self-hosted ClickHouse.
Request flow diagram
Press Play. The numbered list below the diagram lights up with each step.
- You open NiveshKaro. Route 53 answers.
- Static files via CloudFront.
- From S3.
- API calls through the internet gateway.
- The ALB forwards to a pod.
- The trading API checks your order.
- Quotes from ElastiCache.
- Ledger in Aurora; history in DynamoDB.
- Contract note job goes to SQS.
- CloudWatch watches.
- Order placed.
Zerodha versus our AWS design
| Part | Zerodha (public info) | Our AWS design |
|---|---|---|
| Hosting | Two DCs + AWS | AWS only |
| Philosophy | Self-host FOSS on raw EC2 | Managed services |
| Database | Self-hosted PostgreSQL | Aurora PostgreSQL |
| Logs | ClickHouse | CloudWatch Logs |
| Monitoring | Prometheus, VictoriaMetrics | Managed Prometheus |
Quick quiz: check what you learned
What does Zerodha prefer for its software?
- Self-hosted open-source tools
- Only paid SaaS tools
- Mainframes
- No databases
Show answer
A. Zerodha self-hosts FOSS tools.
Where are Zerodha's physical racks placed?
- In the office
- In data centres where exchange leased lines end
- On ships
- In phones
Show answer
B. Two data centres where leased lines terminate.
What did Zerodha move its logs to in 2023?
- Excel
- Oracle
- ClickHouse
- Floppy disks
Show answer
C. Zerodha moved from ELK to ClickHouse and Vector.
How fast does Zerodha make 1.5+ million contract notes?
- 10 hours
- 3 days
- 1 week
- About 25 minutes
Show answer
D. About 25 minutes (2024).
Learn it properly
Build the AWS parts yourself with these free guides and lessons:
- How to create a custom VPC with subnets, internet gateway and route tables
- Public vs private subnet in AWS · 3-tier architecture project on AWS
- How to launch an EC2 instance · Install the CloudWatch agent on EC2
- AWS course: What is a VPC? Default VPC vs custom VPC
- Related architectures: Uber Architecture Explained: 4,000 Services, Kubernetes, Docstore · LinkedIn Architecture Explained: Kafka, FishDB, Rest.li, LLM Feed · Pinterest Architecture Explained: AWS, PinCompute on EKS, MySQL · Instagram Architecture Explained: Django, PostgreSQL, Cassandra
- All famous app architectures explained