How Hotjar Scaled to 500M Daily Requests: 8 Lessons for Rapid Backend Growth

This article chronicles Hotjar's evolution from a simple two‑server setup to a robust, eight‑server architecture handling billions of daily requests, sharing eight practical lessons on scaling, CDN usage, language choice, data storage, monitoring, and cost‑effective optimizations for fast‑growing web services.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How Hotjar Scaled to 500M Daily Requests: 8 Lessons for Rapid Backend Growth

Architecture Evolution

Hotjar started with a simple V1 architecture: a Python backend, AngularJS frontend, PostgreSQL database, and Amazon ELB distributing traffic to two application servers, monitored by New Relic.

The design emphasized simplicity and horizontal scalability.

Current Architecture

As traffic grew to over 150,000 sites, the stack expanded. Eight application servers sit behind a load balancer. Monitoring uses New Relic and Librato; alerts are sent via StatusCake and VictorOps. Intercom and Mixpanel support the marketing team. Logs are collected with Graylog. Data is stored in PostgreSQL, S3, and Elasticsearch. Email is sent via Amazon SES. Redis and Memcached provide in‑memory caching.

Key Takeaways

Plan for rapid growth. Early emphasis on horizontal scaling allowed Hotjar to expand from 2 servers (2 CPU, 3.4 GB RAM) to 8 servers (64 CPU, 120 GB RAM) without major redesign.

Serve static assets via CDN. Moving the tracking script to a CDN dramatically improved load speed and stability.

Choose the right language for performance‑critical paths. Hotjar rewrote a high‑traffic component in Lua (nginx+lua) instead of Python, achieving large latency reductions and lower error rates.

Offload infrequently accessed data to cloud storage. Migrating rarely used records from the primary relational database to S3 saved space and improved query performance.

Use specialized databases for specific workloads. Switching search‑heavy queries from PostgreSQL to Elasticsearch, while writing to both during migration, yielded immediate performance gains.

Optimize script delivery to reduce CDN costs. Splitting the tracking script into a stable business code part and a small per‑user configuration part cut bandwidth and improved load times.

Monitor schema limits and plan migrations. An int4 primary‑key overflow forced a costly data type change and multi‑week migration; better monitoring could have prevented the issue.

Invest in comprehensive monitoring. Adding extensive metrics and alerts enabled rapid issue identification and reduced time spent on debugging.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

monitoringPerformance OptimizationarchitectureCDNdatabase migrationbackend scaling
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.