Design a Login and Authentication
Design the login and authentication system for a large website. People sign up with an email and a password or with a social account, log in, stay logged in for weeks on each device, and can log out of one device or all of them. They can turn on two-step verification and reset a forgotten password. Every page request must know, quickly and correctly, which user is asking.
The site has 100 million accounts and 20 million daily users, which makes about 150,000 page requests a second at peak, each one needing a session check. Logins are rare by comparison, about 150 a second, but each must run a deliberately slow password hash. Attackers try leaked email and password pairs from other sites at 20 times the normal login rate. The hard parts are a session check that is fast enough for every request but can still be revoked at once, a login path that stays up under attack, and stopping account takeovers without locking real users out.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1How do people log in?
- 2How long does a login last?
- 3Must logout and password changes take effect at once?
- 4Do we need two-step verification?
- 5Web only or apps too?
- 6How big is the attack problem?
- 7Do other services check identity?
- 8Is single sign-on for other companies in scope?
How to spend the 45 minutes
- 5minPart 1: Requirements: login methods, session length, revocation
- 5minPart 2: Estimates: checks vs logins vs attacks
- 5minPart 3: API and data model
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Passwords, sessions, stuffing and MFA