Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue #2

Open
christianhellsten opened this issue Sep 15, 2014 · 3 comments
Open

Performance issue #2

christianhellsten opened this issue Sep 15, 2014 · 3 comments

Comments

@christianhellsten
Copy link

I'm benchmarking Hobbit with "hat" and I'm seeing some weird behavior.

I'm using Puma:

puma -t 16 -w 2 -e production

The results are not that great on the latest iMac:

$ wrk -t 2 http://localhost:9292/
Running 10s test @ http://localhost:9292/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     8.27ms    4.75ms  31.29ms   72.14%
    Req/Sec   492.83    232.84     0.91k    51.49%
  8698 requests in 10.00s, 8.04MB read
  Socket errors: connect 0, read 0, write 0, timeout 15
Requests/sec:    869.77
Transfer/sec:    823.12KB

However, if I comment out everything inside the /assets block, plus remove the assets from the layout file, I get a pretty decent result:

$ wrk -t 2 http://localhost:9292/
Running 10s test @ http://localhost:9292/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.16ms    2.42ms  24.30ms   87.62%
    Req/Sec     2.48k   377.00     3.56k    72.97%
  46861 requests in 10.00s, 43.31MB read
Requests/sec:   4686.19
Transfer/sec:      4.33MB

In other words:

map '/assets' do
# removed
end

What's the reason for this slowness, anything that can be done to speed things up?

@patriciomacadden
Copy link
Owner

Hi @christianhellsten.

That's because Sprockets does a lot of things in order to serve your assets (compress them, set headers, etc.). You can use Rack::Static if you want a more performant solution (obviously you won't get an "asset pipeline"). Here is an example: https://github.com/patriciomacadden/hobbit/wiki/Serving-static-files

@christianhellsten
Copy link
Author

Ok, so you're saying it's normal behavior that the /assets block and sprockets is called, even after commenting out these lines in application.erb:

<link rel="stylesheet" href="/assets/application.css"/>
<script type="text/javascript" src="/assets/application.js"></script>

@patriciomacadden
Copy link
Owner

That shouldn't happen. If you don't request any /asset route, Sprockets::Environment shouldn't be called. See how sprockets work: https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/server.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants