1

I'd like to optimize an Odoo-installation with Varnish 4. Odoo uses Python / Werkzeug to deliver HTML. Odoo 8.0rc1 and Varnish 4.0.1-2~trusty on Ubuntu 14.04. Both Odoo/Varnish are installed on the same server. With a simple test using ab I got 117 requests per second without Varnish (on port 8069) and 116 with Varnish. On the serverside I got the Odoo-server slightly more loaded (10%) not using Varnish.

Any ideas?

This is directly to Odoo:

aw@lian:~$ ab -n 1000 -c 20 http://myodoo.example.com:8069/web
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxx (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Werkzeug/0.9.4
Server Hostname:        
Server Port:            8069

Document Path:          /web
Document Length:        251 bytes

Concurrency Level:      20
Time taken for tests:   8.516 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      476000 bytes
HTML transferred:       251000 bytes
Requests per second:    117.42 [#/sec] (mean)
Time per request:       170.323 [ms] (mean)
Time per request:       8.516 [ms] (mean, across all concurrent requests)
Transfer rate:          54.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       29   33   2.5     33      38
Processing:    43  136  28.0    133     226
Waiting:       43  135  28.0    133     225
Total:         73  169  28.3    167     259

Percentage of the requests served within a certain time (ms)
  50%    167
  66%    178
  75%    186
  80%    192
  90%    209
  95%    221
  98%    235
  99%    242
 100%    259 (longest request)

This is via Varnish:

aw@lian:~$ ab -n 1000 -c 20 http://myodoo.example.com/web
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxx (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Werkzeug/0.9.4
Server Hostname:        
Server Port:            80

Document Path:          /web
Document Length:        251 bytes

Concurrency Level:      20
Time taken for tests:   8.603 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      536197 bytes
HTML transferred:       251000 bytes
Requests per second:    116.23 [#/sec] (mean)
Time per request:       172.067 [ms] (mean)
Time per request:       8.603 [ms] (mean, across all concurrent requests)
Transfer rate:          60.86 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       29   33   2.5     33      38
Processing:    66  138  31.7    132     272
Waiting:       66  137  30.1    132     255
Total:         95  171  32.1    166     305

Percentage of the requests served within a certain time (ms)
  50%    166
  66%    178
  75%    186
  80%    194
  90%    212
  95%    233
  98%    262
  99%    279
 100%    305 (longest request)
aw@lian:~$ 
  • I'm also going to try Varnish in front of Odoo. Did you confirm that Varnish is actually caching anything? E.g. through these tools – guaka Sep 18 '14 at 14:37
  • This thread on the Odoo forum is also useful (and I saw you already found it). – guaka Sep 18 '14 at 14:42
0

Varnish is at it's most powerful when you replace the default 'vcl' with your own. By default, that's configured within /etc/varnish/default.vcl (debian).

You'll need to ensure your startup script references that file.

If you've got it open, you can see the default code. Basically, you need to 'unset' the Cookie header, as it's coming through the system, so that varnish can actually cache the item.

By default, you'll at least want to force static media (images, javascript, css) to be forced, akin to as follows:

sub vcl_recv {
    if (req.url ~ "\.(css|js|ico|png|gif|jpg|swf|jpeg|zip)$" ||
            req.url ~ "\.js?ver\=*$" ||
            req.url ~ "\.css?ver\=*$") {
                    unset req.http.cookie; # Cookies not needed here
                    return(lookup);
    }
}

The varnish documentation is really detailed, and goes into how to do basically everything you'll need to do in VCL. I'd strongly reccomend spending a few hours just reading over it:

Docs for v3: https://www.varnish-cache.org/docs/3.0/ v4: https://www.varnish-cache.org/docs/4.0/

Specifically, you'll probably want the 'User guide'.

Varnish is amazingly powerful, but you get out what you put in with it!

Good luck, if you get stuck on anything don't hesitate to ask more questions!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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