
“What happens when you type Google.com into your browser and press enter?” - xvirk
https://github.com/alex/what-happens-when
======
cursork
Love it! One of my favourite bad interview questions. I got asked this in an
interview ~5 years ago. My response was to look shocked... Pause. Then ask:
"What do you mean? What detail do you need? DNS? SYN / ACK? HTTP?"

At the point I started talking about syn/acks they just cut me off and moved
on to the next question.

Same company (different person) started the phone screen with 'oh so your CV
says you know linux, what's the difference between a hard link and a soft
link' and was shocked when I knew the answer, declaring the rest of the phone
interview pretty pointless - he'd obviously had a bad morning and started with
his hardest question.

I've now learnt to see such interview questions as a sign of a workplace with
little-to-no learning on the job. Most places that _actively_ encourage
learning don't try such things.

~~~
nostrademons
That's part of the point of the question - which part you go into detail on is
a pretty good indication where your strengths lie. Someone who spends a lot of
time on DNS and SYN/ACK is probably a low-level networking guru, and the rest
of the interview should be structured accordingly. Someone who immediately
jumps into HTTP requests, HTML parsing, and stylesheet application is probably
a web developer, and the rest of the interview should be structured
accordingly. Someone who talks about the enter key firing off an interrupt
that the keyboard device driver handles and puts into a message queue for the
windowing system's event loop to handle is a low-level desktop OS person.
Someone who talks about the browser retrieving the event from the window loop,
dispatching it the urlbar's hwnd, and kicking off an HTTP request is a Windows
application programmer.

The advantage of this over just looking at someone's resume is that you can
tease out areas of strength beyond someone's particular work experience, so
that if eg. you get someone who's been stuck doing Win32 programming his whole
life but has managed to teach himself a bunch of web technologies on his own
time, he can talk intelligently about the browser's style rendering. It can
also identify areas of cross-training, eg. the bulk of my professional
experience is in web development, but I know enough about how the other layers
of the stack work to write this comment.

~~~
CPLX
And someone who says "duh it shows the Google homepage" is destined for the
executive team.

~~~
brownbat
The executive answer begins "It connects you with the world, but moreso,
connects us all as a society..."

(This answer continues for two hours.)

~~~
ibmthrowaway218
Or:-

"That's a great question! I think the best way to answer it is..."

(This answer continues for two hours without actually answering the question
posed.)

------
eblume
This question always reminded me of the (excellent) book "Zen and the Art of
Motorcycle Maintenance". The author explores the philosophy of engineering as
being the art of separating things in to their components. At the risk of
spoiling some of the book, a major struggle the author goes through is the
paradox that there seems to be an infinite number of ways to split some kinds
of systems, with no productive work ever being done. This question feels like
that... you can split it down to the tiniest discrete system and you'll find
you haven't gained much.

That's not to say that you wouldn't gain SOMETHING, nor that it's a bad
interview question. I actually like it. It's just not terribly productive, in
an engineering sense.

~~~
ekianjo
> that there seems to be an infinite number of ways to split some kinds of
> systems

Indeed、you can even go to the electron level to describe what's happening in
the circuitry and how it interacts with the silicon to propagate signals...
it's never ending.

------
felipesabino
There is also a very good introductory answer in this subject by Jean-Baptiste
Quéru in 2013 [1] where he takes the revers approach of when the page is
displayed, then talks about connection, OS, etc. "simplifying" the answer and
going down several levels of abstraction and complexities to give the proper
overwhelming sense that this question should impose.

It is a very fun text to read and I really recommend it.

[1]
[https://plus.google.com/u/0/+JeanBaptisteQueru/posts/dfydM2C...](https://plus.google.com/u/0/+JeanBaptisteQueru/posts/dfydM2Cnepe)

~~~
wldcordeiro
When I first read the headline I thought of this post as well, my instinct was
that someone had pasted it into a Gist but it seems like a collaborative
project to make an even more detailed answer. Which is neat.

------
Animats
So far, nobody has filled in the section on how a key-press event works its
way through the OS, up to the window system, to the application, and to the
code handling the input text box.

Then there's what's happening at the Google end. Before search
personalization, popular queries ("google", "Britney Spears") were handled by
caches the first Google machine you talked to, and never even reached the
search engine. Since search personalization, there's some cookie traffic, and
then your personal dossier is retrieved from storage at Google for use in
interpreting your query.

Then, in the middle, your query probably travels through five to ten routers
(try a traceroute) just to get to Google. Packets move from local Ethernet or
WiFi to DSL to fiber to bigger fiber to gigabit Ethernet within a Google data
center.

And where is "google.com" for you? That's hard to find out. For me, today,
it's at "nuq04s19-in-f14.1e100.net", wherever that is. My connection routed
from Silicon Valley to Santa Rosa to San Jose before reaching a Google point
of presence at Equinix in San Jose.

Somebody also needs to talk about what's happening in the CPUs, with 3 billion
or so instructions per CPU core every second, all devoted to looking up a cat
video for you.

When you play a cat video, more computation occurs than was done in the
history of the world prior to 1940.

~~~
Florin_Andrei
There's a whole lot of BGP and stuff like that on the interconnect, too.

~~~
spydum
BGP, and usually some internal routing protocol on each end of the ASN path
(likely something like OSPF). But those only inform the forwarding tables,
they aren't an active component of the request. You could always go into the
forwarding logic of the routers and switches as it moves through the network
and TCAMs/DRAM.. As others mentioned, it's practically endless.

------
bobajett
I would really like to know what happens when Im driving down a highway at say
60mph and browsing the web on my smartphone (or well let's say my wife is
doing the driving and Im browsing the web :-) ). What kind of communication is
happening between me and the cellphone towers? What data is my phone sending
to the different cellphone towers as I drive by them? How does the cellphone
tower send that data to the internet? Does someone have a good pointer to a
resource that would answer these questions?

~~~
tinco
Almost everything is exactly the same as on your desktop computer. The only
thing that's different is what goes on under your TCP/IP layers.

Your Phone has a modem built in, that modulates a digital signal over a
carrier wave at a certain frequency (set of frequencies, depending on the
channel access protocol) the modulated carrier wave is sent out to the
cellphone tower.

When the modem is supposed to receive, when it's allowed to send, how it
negotiates these things is all strictly defined by protocols the telecom
industry has standardized on. I can't say I'm an expert on these protocols,
there's a whole bunch of them. They are grouped in protocol stacks with
familiar names like GPRS, EDGE, UMTS, LTE.

These protocols besides making optimal use of their available bandwidth taking
into account all kinds of noise, disturbances, moving from tower to tower,
other phones also specify how the communication should be encrypted.

The encoding/decoding of these protocols is usually done by an integrated
circuit in your phone that's separate from the rest of the phone's
functionality, to prevent you from tampering with it (and to ensure
reliability I guess). So all your phone's general operating system has to do
is interface with that circuit to get neat IP packets.

------
toadi
Can't remember how many jobs I did where the interview questions were the
hardest part of the job. In the beginning you think wow I'm going to get a
nice and existing job.

Just to be dissapointed again because the job consists of fixing bugs in
crappy legacy code and writing CRUD code.

------
imaginenore
The first part is already outdated. A lot depends on the browser. Chrome will
look up stuff as you type it, and by the time you press <enter>, the DNS
lookup will likely have happened already. And, likely, the actual request to
the page.

It's probably even more complicated than that, I believe "google.com" is a
very special case in Chrome.

~~~
jedberg
You should submit a pull request to fix it then. :)

~~~
presty
and ideally with links to the exact lines of code (chromium) that do each
thing ;)

------
TheLoneWolfling
It frustrates me that it just goes "Interrupt fires".

There's a whole lot that goes on between the USB bus receiving the packet and
HID driver - I mean, even making the processor branch is non-trivial.

~~~
aptwebapps
It's a WIP. Scroll down and you'll see a lot more similar headings. The
ellipsis is to indicate that the section is incomplete. Perhaps you can
contribute?

~~~
TheLoneWolfling
I don't know the details of that section myself - I'd love to find out, hence
my disappointment that it wasn't there.

------
cek
I needed a break so I used this as an excuse to try to remember how Windows
actually handled keyboard input. I submitted a pull request:

[https://github.com/alex/what-happens-
when/pull/21](https://github.com/alex/what-happens-when/pull/21)

------
sufianrhazi
I hope people don't study this. The answer to this question doesn't matter.

The whole point of this question is to (1) gauge the clarity of the
candidate's communication when explaining complex systems and (2) have them
get to a place where they simply doesn't know and must start making
assumptions of how things work and weigh the various tradeoffs. That's where
things get interesting.

------
bbarn
By far my favorite question to ask (and be asked) in an interview. As others
point out, it's practically impossible to understand the entire system. At one
point or another in my career I've been exposed to at least descriptions of
most of the components, but if I wanted a processor engineer, I'd be looking
for a different answer than a web developer, or a networking guy, etc.
Essentially anyone involved in the modern world of IT has to be able to answer
something they're good at - and more importantly, admit the parts they don't
understand. You can't cheat your way through the question, hell, you could
even know it's coming and you still can't "beat" it. You don't know if I'm
looking for hyper-detail about something, business sense to skip over
irrelevant (to the position) details of a certain level, etc.

~~~
tonyedgecombe
An experienced developer is almost certainly going to start by asking you more
questions, trying to find out what your expectations are.

------
a3_nm
Wouldn't it be more convenient for people to contribute if this were set up as
a wiki?

------
egypturnash
> The keyboard controller then encodes the keycode for transport to the
> computer. This is now almost universally over a Universal Serial Bus (USB)
> connection, but historically has been over PS/2 or ADB connections.

What about Bluetooth keyboards?

~~~
kevan
Ooh, now we can add a big section on EMR, wireless protocols, forward error
checking, the possibilities are endless!

~~~
Florin_Andrei
Nah, it always ends with Maxwell's equations.

------
robertcope
I didn't know this was so popular of a question. I've been asking it for many
years. I love it because anyone with expertise in any part of the system
should be able to answer it. Are you a networking guru? If so, you should be
able to talk a long time about the network bits. Are you a kernel guru? Same.
Etc. It also gives me a good idea how broad the interviewee is.

It is always amazing to me how many people fail the question so badly. I've
really had only one person answer it reasonably in all these years.

~~~
RogerL
So, everyone fails and you think it is a good question? That doesn't make a
lot of sense to me.

I can't reasonably answer the question, because I haven't really needed to
know it. When I need to know it, I'll learn it, and quickly. How is that
question a good measure of me if you are not hiring me to architect a router
or something where it pertains?

I could ask you questions in my domain that you'd be hopeless at answering.
But I wouldn't, because it would be a horrible measure of you.

~~~
nostrademons
The other thing the question tests for is rigidity of thinking.

You _can_ answer the question - pick whatever part of the stack you're
familiar with and explain what's going on there. If you're a web developer,
talk about how the browser loads the HTML for the page, then pulls out the
<link rel=stylesheet> tags and fetches CSS for them, then executes any
<script> tags. It sees a <form> tag, then an <input type="text">, and uses
that to render the query box. If you type and that and hit submit, it loads
the page in the <form>'s action attribute.

If you're a desktop software guy, talk about how Windows dispatches a
WM_KEYDOWN event, which the browser's event loop picks up. It then initiates
an HTTP request and renders Windows controls for every HTML element on the
page.

If you're a backend database guy, talk about how Google must run a query
against a massively sharded database to look up the terms you just entered and
fetch document URLs for each of them. It then merges the query results to AND
your query terms together, and return them.

Note that all of these answers are completely wrong (and basically the only
way I could know this is because I worked on Google Search and actually know
how it works). Google.com inlines styles into a single <style> tag; there are
no <link> stylesheets, because we found the latency of the HTTP request
outweighs the cache savings. I know less about how Windows works, but I
wouldn't be surprised if under Windows7 and .NET the Win32 API is an emulation
layer, and I know that most of the elements in modern browsers have no OS
analogue and are rendered in shadow DOM via the browsers own box-and-painting
mechanism. And there are no databases involved in Google; the whole web is
stored in RAM and queries are matched & scored against everything (this itself
is an oversimplification, but I'm limited to public information in what I can
disclose...)

It doesn't matter. The point of the question is to get you to reveal what you
know. If you don't reveal anything, you fail. Most people, when faced with a
problem that they don't know the answer to, shut up and don't do anything. For
a lot of tech companies, you want to hire people who will move forward and do
_something_ , even if it's wrong, because you'll have more information to
course correct with a wrong solution than with no solution.

~~~
PhasmaFelis
> _If you 're a backend database guy, talk about how Google must run a query
> against a massively sharded database_

Apropos of nothing, I hadn't realized that "shard" in reference to databases
had made its way beyond MMOs, and I think it's hilarious.

Ultima Online pioneered the MMO concept of using different copies of the game
world, each with their own server and backing database, to partition a large
player base into manageable chunks. These were called "shards" in reference to
the shards of the evil wizard Mondain's Gem of Immortality, which was
shattered at the end of the original 1980 Ultima and caused problems in later
games. The word was informally used for later MMOs' servers, and apparently
it's now _formally_ used for horizontal database partitions.

So, if anyone asks you what a "shard" is in a database context, I recommend
you start by telling them about the terrible legacy of the wicked sorcerer
Mondain.

------
stfp
Just thought I'd point out that this is an old repo from 2013.

Probably should update the title before people starting submitting PRs in a
doomed attempt to "not skip on anything".

~~~
bbarn
The author just merged in a PR from (I'm guessing) an HN reader a few minutes
after adding it.

------
ph0rque
_the time-to-live value for a datagram reaches zero at which point the packet
is dropped_

Someone should write a Victorian-style novel on the hard, short, but virutous
life of a packet.

~~~
praptak
Or a multilevel story-within-a-story type where the browser tells the HTTP
server a story about an OS who tells a story about keyboard interrupts and
network packets and so on.

------
stephen_g
Lots of interesting things happen in between your computer and Google's
servers - like ISPs exchanging routing information using BGP, so the routers
can determine a route through each different AS (provider/transit network) it
has to go through to actually Fong the machine with that IP, and the kinds of
physical and data layers it goes through (cable or DSL, fibre, and Ethernet,
SONET/SDH, maybe tunnelling over MPLS at some point) etc.

~~~
elchief
Is Fonging a thing, or typo? :)

~~~
praptak
This is a question everyone has to Fong out themselves.

------
felipesabino
Computerphile made a good vide on the same subject ~a month ago called "What
Happens When You Click a Link?" [1]

It is obviously not as deep in content as the article is aiming to be,
specially because it focus only on the first things that happens like DNS
resolving and the socket connection, however, it is still fun video.

[1]
[https://www.youtube.com/watch?v=keo0dglCj7I](https://www.youtube.com/watch?v=keo0dglCj7I)

------
kyled
Maybe it's a test to see how well you can communicate? I would of given a very
brief high level overview, such as...

A request is sent to Google's severs for their "new search" page. Google then
responds with the necessary data in order for your Web browser to display the
Web page . There's a lot more to the full story, but I can go into detail if
you would like.

I would offer diving into the important parts related to the position.

------
jodrellblank
People look at you strangely and explain how browser URL bars search for you
in all recent browsers, making the Google homepage irrelevant.

Maybe they explain how home pages and bookmarks and bookmarklets work and set
one up for you.

Nobody explains anything technical; the sort of person who types Google.com
into a URL bar in 2015 isn't very computer literate, and wouldn't care about
the details - any details.

------
mattdesl
Even something as simple as the images and rectangles composited in
hardware/software with Skia would take a thesis to explain.

------
ekr
This would make a great subject for a book, along the lines of NAND2Tetris,
starting at the transistor level or below.

------
jwatte
I have asked this question (more or less,) and the point is to get the
candidate to singer point where they don't know the answer, and then the real
question comes: "so how would you design that next piece?" That's the
interesting part!

------
arkaine
Lack of arp/layer 2 isp, routing.

There is also a mistake inside the DNS part. DNS queries are done from the
client - and this is actually true for a majority of client/server requests -
by opening a dynamic random port above 49152.

------
dead10ck
Wow, judging from the comments in here, there are a lot of people that are in
management positions that are horrible judges of technical ability and value.
This question asks so many things that it doesn't really ask anything at all.
No matter which field they decide dive into, if they can dive into any at all,
it sheds no light whatsoever on their ability to solve problems, or their
ability to learn new difficult concepts. Moreover, making assumptions about
where their specialties lie because of the topic they chose to answer in is
wrong--if they answered well, they could be skilled in many other topics as
well, and if they didn't, that doesn't mean they're incompetent--it means they
didn't know how to answer what is essentially a trick question.

~~~
MichaelMoser123
>it sheds no light whatsoever on their ability to solve problems, or their
ability to learn new difficult concepts.

This is of course correct; one way to check for these is to ask specific
questions for prior job experience; however the top-dog companies like to hire
promising graduates right out of college and so they don't wish to cut them
off by asking these questions.

------
dogweather
I prefer to ask open-ended questions more calculated to give me an idea of
where the interviewee's head is at:

"What's your favorite programming language? Why?"

------
avmich
I'd like to see a detailed description of sockets work.

------
MarcScott
I'm going to watch this carefully. Once it's complete I plan to base a scheme
of work on it for my secondary school CS students.

~~~
jtheory
"Once it's complete" indeed... and to draw _that_ particular random line in
the sand?

------
_almosnow
>17.78 mA of this current is returned on either the D+ or D- pin (the middle
2) of the keyboard's USB connector.

Oh, so we will look at it at THAT level of detail, nice.

Then hardware interrupts, seems ok...

Then HSTS and DNS, yeah, no, you are skipping like 3 more pages of things that
happen in between. Good luck with your naive experiment.

~~~
davegonzalez
Isn't that the point of having others help and fill in the gaps? What's the
point of belittling it to a "naive experiment"?

------
hadrian
"I don't normally watch github projects, but when i do, it's projects like
these :D "

------
nzealand
His emphasis on lower level protocols is not what I would expect a python
programmer.

I wonder what the following would say about me in an interview situation...

Device specific rendering. Localization and Language logic. Image download and
display. Screen rendering. Caching, cookies & browser history. Analytics
integration. Account lookup. The search being saved on the backend.

