It’s been a while since I was on the receiving end of a software engineering
interview. But I still remember my favorite interview question. It was at MemSQL circa 2013.
(They haven’t even kept their name,
so I assume they’re not still relying on this specific interview question.
I don’t feel bad for revealing it. It’s a great story that I tell people a lot;
I’ve just never blogged it before.)
Okay, so this isn’t a “question” per se; it’s a programming challenge.
I forget how much time they gave for it. Let’s say three hours, counting
the time to explain the problem.
Since MemSQL was a database company, this is a database challenge.
Introducing memcached
You know about memcached
? No? Well, it’s an in-memory key-value store.
(Read its About page here.) Let’s download
its code and build it so I can show you what it does.
You may need to
brew install libevent
and maybe some other
stuff in order to build memcached successfully. It won’t be too
difficult to figure out; but anyway, wrangling with your environment
wasn’t part of the test. You can assume interviewees were given
access to a Linux box with all the right dependencies in place already.
For the authentic 2013 experience, let’s bypass the GitHub repo
and untar a contemporary source distribution:
curl -O https://memcached.org/files/memcached-1.4.15.tar.gz
tar zxvf memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure
make
Now we’ve built the memcached
executable. Let’s start it running:
We can talk to the server via the default memcached port, port 11211.
Its protocol is basically plain text, so we can use plain old telnet
to talk to it. (If you don’t have telnet
anymore, substitute the
words nc -c
for telnet
.)
$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Playing with memcached
memcached is a key-value store. That means we can t