-3

I am building an autocomplete functionality for my site and the Google instant results are my benchmark.

When I look at Google, the 50-60 ms response time baffle me.

enter image description here

They look insane. In comparison here’s how mine looks like.

enter image description here

To give you an idea my results are cached on the load balancer and served from a machine that has httpd slowstart and initcwnd fixed. My site is also behind cloudflare

From a server side perspective I don’t think I can do anything more.

Can someone help me take this 500 ms response time to 60ms? What more should I be doing to achieve Google level performance?

Edit:
People, you seemed to be angry that I did a comparison to Google and the question is very generic. Sorry about that.

To rephrase: How can I bring down response time from 500 ms to 60 ms provided my server response time is just a fraction of ms. Assume the results are served from Nginx -> Varnish with a cache hit.
Here are some answers I would like to answer myself assume the response sizes remained more or less the same.

  1. Ensure results are http compressed
  2. Ensure SPDY if you are on https
  3. Ensure you have initcwnd set to 10 and disable slow start on linux machines.
  4. Etc.

I don’t think I’ll end up with 60 ms at Google level but your collective expertise can help easily shave off a 100 ms and that’s a big win.

Quintin Par
  • 4,293
  • 10
  • 46
  • 72
  • 4
    Do you have a few hundred million dollars to throw at the problem? – EEAA May 28 '14 at 03:07
  • @EEAA, if the answer was yes, would you be able to answer? Frankly, Google's distributed searching architecture is mindblowingly fast. Even making some idealizing assumptions like "much smaller dataset" and "zero network latency", I don't have a clue how you would build a system that would scale compute resources even quadratically to searchtext size. QuintinPar, If you aren't using a purpose-built fulltext engine like elasticsearch or lucene, you should try one. If you want to make your question better, please add more details of your backend system. Any cache miss is going to be costly. – Andrew Domaszek May 28 '14 at 03:40
  • @AndrewDomaszek - in excruciating detail? No. In general themes, absolutely. – EEAA May 28 '14 at 03:42
  • As much as I would like to pursue this discussion with someone as versed as you on the subject (which would be an answer to the original question), I realize this is not the appropriate medium for it. I do think it would contribute positively to S.F., were the subject not so broad. – Andrew Domaszek May 28 '14 at 04:00

2 Answers2

2

Important things to look for in order to achieve similar performance are these:

  • Roundtrip time between client and server. Google has deployed servers all around the globe in order to always have some close to the client.
  • Number of network roundtrips needed. Opening a TCP connection and sending an HTTP request requires at least two roundtrips. More roundtrips are needed for HTTPS. Find out how many roundtrips are used, and if it is technically feasible to reduce it. If connections are kept alive between requests, it should be feasible to do requests in one roundtrip.
  • Pay attention to dependencies between requests. Is the page structured in a way where all resources can be downloaded in parallel, or are they downloaded sequentially?
  • Have enough RAM on the server. If you want to squeeze every last millisecond of performance out of a system, you cannot afford to wait for a disk seek.
  • Avoid linear algorithms. If the server need to use time linear in the data size in order to respond to a request, it is unlikely to perform well. Algorithms that are logarithmic in the size of the data you are searching in should do just fine, if the data is resident in memory.
  • Pay attention to resource usage. Does any network link get saturated, does network roundtrip times increase when the server is receiving requests, does something use additional memory on the server and push your data structures out of RAM?
kasperd
  • 29,894
  • 16
  • 72
  • 122
0

Not a duplicate but very similar question asked here:

https://stackoverflow.com/questions/132359/how-can-google-be-so-fast

It may help you get some more insight as to what's been done by Google to achieve better results.

captcha
  • 568
  • 5
  • 16
  • Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – EEAA May 28 '14 at 03:41