12

(Question edited b/c I have realized it involves file type)

This file is 20kb. It is consistently taking > 1 second to serve.

http://www.adrenalinemobility.com/js/ss-symbolicons.js

Here is the same file with .css as it's extension:

http://www.adrenalinemobility.com/js/ss-symbolicons.css

It serves almost 1 whole second faster.

Here is my app.yaml:

application: adrenaline-website
version: 1
api_version: 1
runtime: python27
threadsafe: true

libraries:
- name: jinja2
  version: latest

handlers:
- url: /favicon\.ico
  static_files: assets/favicon.ico
  upload: assets/favicon\.ico

- url: /css
  static_dir: assets/css

- url: /img
  static_dir: assets/img

- url: /js
  static_dir: assets/js

- url: /.*
  script: web.APP

I've also tried this static_files line (before the /js handler), and it was slow too:

- url: /js/ss-symbolicons.js
  static_files: assets/js/ss-symbolicons.js
  upload: assets/js/ss-symbolicons.js

Ways I have observed this:

  • Chrome, Firefox (both on Linux) - from a DSL connection in Silicon Valley
  • wget, curl, etc from that machine.
  • Remotely wget and curl from a high-speed server at the University of Illinois
  • Remote web testing services like webpagetest (see below):

Here's a webpagetest waterfall graph that illustrates this problem - notice the one file has a huge TTFB: http://www.webpagetest.org/result/131101_ZQ_ZGQ/1/details/

If i manually set the mime_type to text, then it goes fast. application/javascript, application/x-javascript, text/javascript are all slow. Currently those files are serving without manually specified mime-type if you wish to test.

Some more info, as noticed by jchu:

The slow version serves with: Content-Length: 19973 and the fast version serves with: Transfer-Encoding: chunked

Still more details:

I usually get server 74.125.28.121. Someone on reddit got server 173.194.71.121 and it seems to have even serving speeds between them. So maybe it's server/location dependent?

Another post about this issue

Here is a pastebin with full curl logs of requests for both files

Here is another pastebin with just the timing information from ten requests on each file in a tight loop

14
  • Please show us the efforts that you have taken in this regard. Nov 1, 2013 at 17:56
  • 2
    Do you understand app engine static serving? I mentioned that I use their cache infrastructure; There really aren't any other options that I know of. Please don't comment if you don't understand the domain of the question.
    – Murph
    Nov 1, 2013 at 17:59
  • I am sorry for the careless reading on my part. So, you are implementing the static file serving or not? And, there isn't any other faster implementation other than their own static_file handlers. Nov 1, 2013 at 18:02
  • I'm actually using the static_dir handler - I assume it should be as fast? I just don't believe that > 1 second to begin serving a static file is acceptable - something must be wrong.
    – Murph
    Nov 1, 2013 at 18:04
  • 1
    Added my app.yaml. The problem is with the real server, not the dev server, so that post doesn't help.
    – Murph
    Nov 1, 2013 at 18:29

2 Answers 2

3
+50

Add mime_type: text to your JavaScript static resource.

Would need to look into what mime_type is being assumed, what what clever trick is being done for text vs other mime types...

12
  • I get the same behaviour if I query the file multiple times in a single minute. 14:00:41: 1.272s, 14:00:46: 1.213s, 14:00:49: 1.077s
    – Murph
    Nov 1, 2013 at 19:01
  • I wrote a bash script, and am not seeing any lag. It is very steady at around 100ms for me.
    – bwawok
    Nov 1, 2013 at 19:05
  • Same, and I'm using a very quick server to check from. Are you pulling the actual file (The cache not modified response is much faster)?
    – Murph
    Nov 1, 2013 at 19:07
  • yes wget in a loop. Let it set 10 minutes, and you will see it slow. Pull it in a tight loop, and you will see it fast.
    – bwawok
    Nov 1, 2013 at 19:08
  • When loading your whole site, the only thing slow I see is: anonymoususerspace www.linkedin.com/uas/js, but that is on the order of 100ms.
    – bwawok
    Nov 1, 2013 at 19:10
2

I've been seeinig the same behavior.

GAE has some strange edge caching behavior for these javascript files. After the 4th or fifth consecutive request, the response time improves significantly (some type of edge caching of the gzipped content kicks in). In my experiments it's gone from around 1.2s -> 190ms

I've been able to reproduce this consistently across 3 GAE apps. If you use Chrome, you can go to the DevTools settings and disable cache (while DevTools is open). Reloading the page a few times will get your javascript transfer times down to the reasonable numbers.

Google's edge cache probably has some logic where it determines it won't bother caching gzipped js files until they're requested frequently enough. This would appear to encourage you to write a script that constantly downloads your js files to ensure that they download a few hundred milliseconds faster. I suspect that the edge cache is smart enough to only cache for one region at a time though.

7
  • I don't see the speedup. I just did 100 requests in a tight loop, still the same slowdown. :/
    – Murph
    Nov 13, 2013 at 0:46
  • Couple of things I noticed: It seems to take a certain amount of time (about a minute?) before it's cached and quick, regardless of the number of hits in that first minute. One big difference I've noticed between my test file 90KB in 132ms vs your file 7KB in 1.02s is that your max-age is 600 while my max-age is 2592000 (30 days). Try playing with the max-age to see if it has an effect (but don't set your max-age on your actual file so high unless you're really ok with it being cached so long). The other odd thing I see are some non-ascii characters in your script comments.
    – dragonx
    Nov 14, 2013 at 16:39
  • In case you want to compare, I'm trying with this file: dine-o.com/scripts/…
    – dragonx
    Nov 14, 2013 at 16:40
  • Odd, mine never gets fast. I just did several hundred hits spread out with spaces in between them. I see yours as fast, though. Maybe it has to play with content or size or max age. Hrm...
    – Murph
    Nov 14, 2013 at 17:52
  • Sorry, I should have mentioned, I also noticed yours never gets fast, which is why I suggested those other variables (since I'm not able to change them on yours).
    – dragonx
    Nov 14, 2013 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.