0

Magento CE 1.9.0.1 with Varnish 4.0.3 & Turpentine 0.6.8

When I load the page or inner pages for the first time those are slow(as First bite is always slow) and on second attempt it becomes quicker coming from Varnish, now since page has been stored in Varnish cache is should be served faster(coming from Varnish) no matter which connection or network I use, but in my case if at same time I go to another PC/network(or sometimes even different browsers on same PC) and try to load the same page it becomes slow. I am using all the default settings of Turpentine in my VCL config.

Here is my /etc/varnish/varnish.params

# Varnish environment configuration description. This was derived from
# the old style sysconfig/defaults settings

# Set this to 1 to make systemd reload try to switch vcl without restart.
RELOAD_VCL=1

# Main configuration file. You probably want to change it.
VARNISH_VCL_CONF=/home/www/vhosts/example.org/httpdocs/var/default.vcl

# Default address and port to bind to. Blank address means all IPv4
# and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted
# quad, or an IPv6 address in brackets.
VARNISH_LISTEN_ADDRESS=99.25.55.148
VARNISH_LISTEN_PORT=80

# Admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082

# Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret

# Backend storage specification, see Storage Types in the varnishd(5)
# man page for details.
VARNISH_STORAGE="malloc,12G"

# Default TTL used when the backend does not specify one
VARNISH_TTL=120

# User and group for the varnishd worker processes
VARNISH_USER=varnish
VARNISH_GROUP=varnish

# Other options, see the man page varnishd(1)
DAEMON_OPTS="-p thread_pool_min=5 -p thread_pool_max=500 -p thread_pool_timeout=300 -p cli_buffer=16384 -p feature=+esi_ignore_other_elements -p vcc_allow_inline_c=on"
  1. Could it be because I am storing everything in RAM as VARNISH_STORAGE="malloc,12G" and there might be a default behavior of memory to just wipe out after every minute or second and I also need to save in SSD? or there could be another issue?

  2. If you say "First bite is always slow" than does it mean it will be slower for each different browser, and each session/connection? this is what is actually happening with me.

  3. Almost all the stores I have seen which are providing page in like milliseconds(having Varnish) does not encounter the same issue. When I browse those sites from various connections it all looks same with pretty much same speed. How can I achieve this?

Please also look at Admin > System > Configuration > Caching Options which may help to answer

enter image description here enter image description here enter image description here enter image description here

  • you need to disable VCL Fix in varnish settings, in cache settings you need to configure proper cookie regex, to serve right domain cookie. – MagenX Mar 22 '16 at 8:55
  • Disabling the VCL fix makes the website vulnerable to CSRF attacks. It's explicitly stated in the Turpentine's documentation. So it's either fast but vulnerable website or bit slower but secure. Unless you start playing with the VCL file but it takes some good knowledge and time. Mind you, though, I don't have a solution yet. I'm struggling with this issue as well. – Ventus Jul 1 '16 at 8:18
1

Could it be because I am storing everything in RAM as VARNISH_STORAGE="malloc,12G" and there might be a default behavior of memory to just wipe out after every minute or second and I also need to save in SSD? or there could be another issue?

No, if your Varnish is set up correctly this should not happen.

If you say "First bite is always slow" than does it mean it will be slower for each different browser, and each session/connection? this is what is actually happening with me

Yes, if you are using the VCL Fix option (which is the default), then the first request is always passed through Varnish to Magento to get a proper session ID. This means, if a request come to Varnish that does not have a frontend cookie set, then it will pass that request through to Magento - which generally means a slower page load. The second request for that same page should be much faster, as well as for other pages that are already in the Varnish cache. This page from our wiki gives more information about ways to make sure Varnish is set up and working properly.

... but in my case if at same time I go to another PC/network(or sometimes even different browsers on same PC) and try to load the same page it becomes slow.

In this case, when you go to another PC/network you're starting a new session, which means the first page request is getting passed through to Magento get a good session ID.

Almost all the stores I have seen which are providing page in like milliseconds(having Varnish) does not encounter the same issue. When I browse those sites from various connections it all looks same with pretty much same speed. How can I achieve this?

They may not be using the VCL fix, or they may just have a very fast Magento site even w/out Varnish - and only be using Varnish to improve concurrency.

Varnish/Turpentine is a very useful tool, especially to improve concurrency - but it's not a replacement for properly optimizing your site/environment as much as possible.

  • Disabling VCL fix in Turpentine's configuration disables CSRF protection as well. Think twice before you disable it. – Ventus Jul 1 '16 at 8:19
-1

I know that turpentine varnish does not serve a site from cache, if the user visiting it, has no frontend session id. I think this is a needed step since magento1 does not support varnish out of the box.

So any user getting on a Site without a valid session will not get the content served from varnish which explains why you have the higher loading time when switching the browser / PC.

This can be looked up here under troubleshooting: https://github.com/nexcess/magento-turpentine/wiki/FAQ

  • but it was not happening like this before(as much), and there are people using Turpentine with Varnish with perfect blend that I don't feel this issue with them. – T_Flows Mar 21 '16 at 21:11
  • I'm not sure what you have seen before and also I'm honestly not sure if there are magento1 modules that solved this issue, but unfortunately im pretty sure that turpentine handles it like that ;) – David Verholen Mar 21 '16 at 21:14
  • this is wrong, Turpentine works very good for the first visit on cached page if no session cookie. – MagenX Mar 22 '16 at 8:53
  • ok, you seem pretty sure about this ... last time I checked (like 2 months ago?) there was a policy in the vcl file that passes through any request without a session cookie .. still the faq of the module also says the same ... – David Verholen Mar 22 '16 at 9:01
  • ok, you are right :P they changed it and theres some method now called generate_session which I assume generates a session – David Verholen Mar 22 '16 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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