Library / Case Studies
TripAdvisor Architecture - 40M Visitors, 200M Dynamic Page Views, 30TB Data - High Scalability -
This is a guest post by Andy Gelfond , VP of Engineering for TripAdvisor. Andy has been with Tr...
By High Scalability engineers · High Scalability · Added 2026-10-12
All content belongs to High Scalability engineers / High Scalability. We only link to it and give credit. Report a problem
Learn this case study
About 37 min left. Your work is saved as you go.
What you are about to study
High Scalability explains a real system. You should know the basics: caching, queues and replication.
Ideas you will meet
- Distributed Systems
- Consensus, time, failure and the fundamentals of scale-out.
What we already know about this
Our own lessons on these ideas. Read them here before you start, so it makes sense.
Networking and Web Security Deep Dive · 13 minJWT, cookies, CORS and security headersTokens and the browser's rules: what is inside a JWT, where to store tokens, what CORS really controls and the headers worth sending.Read here
Cookies and sessions, quickly
A session keeps a user logged in. The usual approach: after login the server creates a random session id, stores session data server-side, and sends the id in a cookie. (Passwords and sessions are detailed in their own lesson.) Good cookie flags:
Flag Effect HttpOnlyJavaScript cannot read it, limiting theft through XSS SecureSent only over HTTPS SameSite=Lax/StrictLimits cross-site sending, reducing CSRF Path,DomainLimit where it is sent Max-Age/ExpiresLifetime; keep session cookies short-lived with renewal JSON Web Tokens (JWT)
A JWT is a compact, signed token with three dot-separated, base64url parts: header (algorithm), payload (claims) and signature.
100%Figure SDA-NSD-04-1 · Anatomy and checking of a JWT · © forcsguy.com
Why use them: the API can verify a token without a database lookup, which suits services and mobile apps. The cost: a stateless token is hard to revoke before it expires.
Good practice
- Keep access tokens short-lived (minutes) and use refresh tokens (stored carefully, rotated, revocable) to get new ones.
- Always verify signature,
exp,iss(issuer) andaud(audience); pin the algorithm. - A JWT is signed, not encrypted: do not put sensitive data in it (use JWE if you must encrypt).
- Where to store in a browser: HttpOnly cookies resist XSS theft but need CSRF protection;
localStorageis readable by any script, so an XSS leaks the token. There is no perfect answer: choose with your threat model, and prevent XSS first. - For simple server-rendered apps, server-side sessions are often simpler and easier to revoke than JWTs. (Federated login with OAuth and OpenID Connect is in the SSO lesson.)
Same-origin policy and CORS
Browsers enforce the same-origin policy: a page from one origin (scheme, host and port) cannot read responses from another origin. CORS (cross-origin resource sharing) is how a server opts in to being read by specific other origins.
100%Figure SDA-NSD-04-2 · A cross-origin request with a preflight · © forcsguy.com
Key points:
- CORS protects users' browsers, not your server. It does not stop
curl, scripts or other servers from calling your API; you still need authentication and authorisation. - A simple request (GET or simple POST with plain headers) is sent directly; the browser only decides whether the page may read the response. Other requests get a preflight.
- Configure exact origins, not
*, when credentials are involved.Access-Control-Allow-Credentials: truecannot be combined with*. Never blindly echo theOriginheader. - Limit allowed methods and headers; cache preflights with
Access-Control-Max-Age.
Security headers worth sending
Header Purpose Strict-Transport-SecurityTell browsers to use HTTPS only for your domain Content-Security-PolicyRestrict script, style, frame and connection sources; mitigates XSS and clickjacking X-Content-Type-Options: nosniffStop browsers guessing content types Referrer-PolicyLimit referrer information sent to others Permissions-PolicyTurn off powerful browser features you do not use Cross-Origin-Opener-Policy/Cross-Origin-Resource-PolicyIsolate your pages from other origins Caching headers and compression
Cache-Controlcontrols caching:public, max-age=31536000, immutablefor fingerprinted static files;no-storefor sensitive responses;privatefor per-user responses that shared caches must not store.ETag/Last-Modifiedallow cheap revalidation (a 304 response with no body).- Compression (gzip, Brotli) shrinks text responses a lot. One caution: compressing responses that mix secrets with attacker-controlled text over TLS can enable attacks such as BREACH, so avoid reflecting secrets and use per-request tokens.
- Do not cache authenticated pages in shared caches by accident; set
Varycorrectly.
Checklist
Cookies: HttpOnly, Secure, SameSite. Tokens: short-lived, verified fully, no secrets inside. CORS: exact origins, minimal methods. Headers: HSTS, CSP, nosniff, frame protection. Caching: private or no-store for user data.
Real-world reading
Related reading
- MDN: Cross-Origin Resource Sharing (CORS)MDN contributors · MozillaDocumentation
- Introduction to JSON Web TokensAuth0 · jwt.ioDocumentation
- RFC 6749: The OAuth 2.0 Authorization FrameworkIETFDocumentation
- MDN: HTTP cachingMDN contributors · MozillaDocumentation
Show 6 moreShow fewer
- HTTP/3: the past, the present, and the futureCloudflareBlogs
- System Design 101ByteByteGo · ByteByteGoHqGitHub
- High Performance Browser NetworkingIlya Grigorik · O'ReillyBooks
- RFC 9114: HTTP/3IETFDocumentation
- Distributed SecurityMicrosoft engineers · MicrosoftCase Studies
- TripAdvisor Architecture - 40M Visitors, 200M Dynamic Page Views, 30TB Data - High Scalability -High Scalability engineers · High ScalabilityCase Studies
Go deeper on this
A path through videos, articles, other case studies and code on the same ideas as TripAdvisor Architecture - 40M Visitors, 200M Dynamic Page Views, 30TB Data - High Scalability -.
Warm upGet the vocabulary first.
Books · Free from the author
Concurrent and Distributed Systems (Cambridge lecture notes)
Eight lectures on time, broadcast, replication, consensus and transactions, with notes, slides and video. Free from the author under CC BY-SA.
University of CambridgeIntermediate
Books · Free from the author
Computer Networks: A Systems Approach
How networks are built and why: protocols, routing, congestion control and the internet's architecture. The authors publish it free online under CC BY 4.0.
Systems ApproachIntermediate
WatchHow others solve the same problem, on video.
Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)
ReadEngineers explain it in their own words.
Blogs · Free from the author · Read here
Scalable Web Architecture and Distributed Systems
A full chapter on the building blocks of large websites: availability, performance, reliability, scalability, caches, proxies, indexes, load balancers and queues. Free to read here under CC BY 3.0.
The Architecture of Open Source ApplicationsBeginner40 min
Papers · Read here
Facebook’s photo storage
This paper describes Haystack, an object storage system optimized for Facebook’s Photos application. Facebook currently stores over 260 billion images, which translates to over 20 petabytes of data.
USENIXIntermediate
See it in another companyThe same ideas, a different system.
Case Studies · Read here
Aroma: Using ML for Code Recommendation at Facebook
Thousands of engineers write the code to create our apps, which serve billions of people worldwide. This is no trivial task—our services have grown so diverse and complex that the codebase contains…
FacebookIntermediate
Case Studies · Read here
Brooklin: Distributed Service for Near Real-Time Data Streaming at LinkedIn
Brooklin—a distributed service for streaming data in near real-time and at scale—has been running in production at LinkedIn since 2016, powering thousands of data streams and over 2 trillion messages per day. Today, w...
LinkedInIntermediate
Read the codeSee how it looks when it is real.
GitHub
Engineering Blogs
A huge directory of company engineering blogs to learn from real production systems.
kilimchoiIntermediate
GitHub
Awesome Scalability
Curated reading list of articles on the architecture of scalable, reliable systems.
binhnguyennusIntermediate
Keep learning
Loading community…