Home > commentary > The 1 Millisecond Page

The 1 Millisecond Page


I had an epiphany today while writing some code. I was writing a utility for web apps to query the WURFL dataset to determine if the remote client is on a mobile device or not. The WURFL dataset has all the manufactured mobile devices with their user agents and capability profiles. There are about 15,000 devices and consequently about 15,000 device records. Not everyone may think it’s a good idea to query at runtime 15,000 records for every request, but I really wanted to make it work.

Everyone wants to get their query times low, and there’s a lot of satisfaction knocking time off and running tight and lean. After some tinkering, I got my query time for this mobile device detection down to 0 seconds. That’s Zero. It was a moment of Zen for me. Seeing the profiler say 0 seconds is just not the same as 0.001 seconds or anything else. In theory of course it took some time, but having the calculation come out to 0 for a very non-trivial feature got me thinking: how many other features can I get down to 0 seconds?

What if all the features of a web page took 0 seconds? Impossible? I have written several applications and the target server time for generating a page is around 250 milliseconds, or 1/4 of a second. This includes checking for authorization, querying the data, formatting the data, dynamically generating the HTML, and even translating it into a foreign language, all on the fly. So I know 250 milliseconds is possible because I’ve done it repeatedly. I also realize that going from 500 milliseconds to 250 milliseconds is easier than going from 250 milliseconds to 0 milliseconds.

But processors and RAM are getting faster, SSD drives may totally change the time profile of data retrieval, MarkLogic will itself get faster, as will web application code. So at some point, someone is going to write a web application where the server time to generate the HTML for it will take 1 millisecond. That will be faster than the TCP overhead of the computers trying to negotiate a connection to each other.

Gone are the days of pages taking 10 seconds to load or your visitor goes away. Now the expectation is that server-side HTML response is sub-second. For my stuff, I aim for 250 milliseconds, and that’s very doable, and I often seen times of 60 to 70 milliseconds (under load with 1000 concurrent users, on one box, checking auth for each request, etc. etc). But now I’m thinking that’s too long. I’m going to expect sub-100 millisecond pages for now, but I’m going to ultimately be looking to cross the 1 millisecond boundary, but a lot of that will come from hardware improvements.

Maybe this is like the sound barrier or the 4 minute mile, where it sounds crazy until it is actually done by someone, and then it’s the new standard. For dynamic, non-trivial web applications, I don’t think any technology would be more likely than MarkLogic to be able to pull it off. And I don’t think it’s really that far off in the future.

Happy coding.

Categories: commentary
  1. khromov
    November 19, 2011 at 4:52 pm | #1

    Interesting post.

    I’d really like to read about some of the optimizations you made to get the query time down so low.

  2. November 19, 2011 at 7:22 pm | #2

    Most of it is because of MarkLogic. It indexes all the values, relationships, etc. in the XML files so when I execute a query, MarkLogic returns the answers extremely fast. This is why I like MarkLogic: it’s really, really fast, even with very large data sets. I understand conceptually how the server works and I know how to write code that is fast, but I don’t know exactly how they implemented the server. That’s why they get paid big bucks.

  1. November 18, 2011 at 5:54 pm | #1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.