For anyone here who is interested (Hopefully Staff) :)

Discussion in 'Feedback and Suggestions' started by TheGremlin, Jun 30, 2015.

  1. TheGremlin

    TheGremlin New Member

    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    SOLVING THE DREADED VARNISH 503 ERROR

    “Error 503 Service Unavailable” / “Guru Meditation” is probably the most common error people get with Varnish. This post will go through a few causes of (and solutions to) this Varnish 503 error.

    BEFORE WE START
    One of the most confusing (but nonetheless very cool) things about Varnish is that it does not store any logs on disk. All log entries go directly into memory. This allows for better performance and efficient disk usage.

    So to view the logs, you’ll have to fire the following command: varnishlog

    Once the command is running, load up a page from your website on your browser and look for any errors. This literally means looking for the word “error”.

    Pretty sweet, huh! Now let’s get on to our first solution.

    SOLUTION 1 – GENERAL CHECK
    Most of the times, Varnish 503 means Varnish cannot connect with your backend (Apache, Nginx, etc…). So you should start from there.

    The first thing is to make sure your backend is correctly configured. That means making sure your Apache/Nginx/whatever is running properly before installing Varnish.

    If you’ve installed Varnish on a properly running instance, then you might just check that installing Varnish hasn’t done anything funny to your Apache configurations. Here’s what you can do:

    Open your Varnish configuration file. Mine was in /etc/varnish/user.vcl

    backend default {
    .host = "127.0.0.1";
    .port = "8888";
    .connect_timeout = 1s;
    }
    We can see that Varnish is trying to connect to port 8888 on the same machine. But is our backend responding correctly there?

    Let’s try this (make sure you run this on your server, this port will probably be blocked to the outside world):

    wget http://www.your-site.com:8888
    This will create an HTML file with the output in your current directory. Open the file and see if it matches your website’s homepage. If it does not, then you need to configure your server. This is beyond the scope of this post, I’ll advise you to check the Linode Library for resources.

    SOLUTION 2 – INCREASE TIMEOUTS

    A frequent cause of Varnish 503 errors is timeouts between Varnish and your backend. This is quite easy to solve.

    Open your Varnish configuration file (mine was in /etc/varnish/user.vcl) and add these lines:


    backend default { .host = "127.0.0.1"; .port = "8888"; .connect_timeout = 1s; # Wait a maximum of 1s for backend connection (Apache, Nginx, etc...) .first_byte_timeout = 5s; # Wait a maximum of 5s for the first byte to come from your backend .between_bytes_timeout = 2s; # Wait a maximum of 2s between each bytes sent }


    The settings are pretty straightforward. The most important settings here is thefirst_byte_timeout. So go ahead and play with those settings until you find the sweet spot for your server.

    SOLUTION 3 – TURN KEEPALIVE OFF
    If you’ve increased the timeouts and you’re still getting Varnish 503 errors, then the problem might be elsewhere.

    Do this test; increase your timeouts to a considerable amount, like 10 seconds. Then, start browsing your website until you get a 503 error. If the error comes up before those 10 seconds, then the error is definitely elsewhere. I’ve seen cases where the error was coming up right after the click, as if the page was cached locally.

    The solution to this issue is quite simple. It occurs often on Apache servers and it’s all due to the KeepAlive directive.

    Open your Apache configuration file. Mine was in /etc/apache2/apache2.conf

    #
    # KeepAlive: Whether or not to allow persistent connections (more than
    # one request per connection). Set to "Off" to deactivate.
    #
    KeepAlive Off
    By turning the KeepAlive directive off, we are forcing Apache to drop idle connections. Turning KeepAlive on makes sense when your Apache instance serves files directly to the end users. Basically the end user will open one connection and receive multiple files from it.

    But with Varnish and Apache on the same server, I’d advise you to turn KeepAlive Off.

    WRAPPING UP
    So there you go with my suggestions. Go ahead, try them and let me know if you have any other solutions!


     
  2. bdistler

    bdistler Well-Known Member Prime Account

    Messages:
    3,534
    Likes Received:
    196
    Trophy Points:
    63
    IMO - most - if not all - of this thread is not applicable for x10hosting's cluster(s) - virtual servers(50+) setups - and networks
     
    Last edited: Jun 30, 2015
  3. Dead-i

    Dead-i x10Hosting Support Ninja Community Support

    Messages:
    6,084
    Likes Received:
    364
    Trophy Points:
    83
    Hi,

    While I appreciate that you've found an article on Varnish, the article you have found describes how to configure Varnish. Our Varnish and Apache setup is already configured correctly, and this information does not really apply for intermittent 503 error messages. We are already aware of how Varnish works, and our Apache & Varnish configuration is already working correctly.

    Just to clarify, a 503 error message is shown when Varnish is unable to communicate with Apache. This can happen when the script you are accessing takes longer than 30 seconds to produce a response, or the web server is temporarily experiencing issues. If Apache is under more load than usual, a 503 error message may be served if Apache is unable to serve the request.

    Our free hosting monitoring system does not show any issues in the last few hours, and I can't see any issues with 503 errors at this time. If you are seeing 503 error messages on your site, please report this in the Free Hosting section.

    Please let me know if you have any further questions.

    Thank you,
     
  4. caftpx10

    caftpx10 Well-Known Member

    Messages:
    1,512
    Likes Received:
    112
    Trophy Points:
    63
    When I got the error and created a thread, you had replied saying that you couldn't see it logged. Was what was suggested in this thread (varnishlog) or something similar used?
     
  5. TheGremlin

    TheGremlin New Member

    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    If not applicable, then why are the boards full of complaints about 503 errors ? It is obviously an issue, if this is not the cause, then what is ? and why not figure it out and fix it. ?
     
  6. bdistler

    bdistler Well-Known Member Prime Account

    Messages:
    3,534
    Likes Received:
    196
    Trophy Points:
    63
    what I said was - the cure-all solutions in your post (#1) are not applicable to the configuration of x10hosting's clustered virtual servers - and the hardware - and the networking ( interconnecting ) they use
     
  7. Dead-i

    Dead-i x10Hosting Support Ninja Community Support

    Messages:
    6,084
    Likes Received:
    364
    Trophy Points:
    83
    Hi,

    Currently, there are no issues with 503 errors, and I have already responded to all support threads about the 503 errors. I have also offered an explanation for the common causes of 503 error messages, in my previous post. Is there anything else I can help with? :)

    Thank you,
     
  8. glennemlee95

    glennemlee95 Member

    Messages:
    59
    Likes Received:
    2
    Trophy Points:
    8
    Hold up a sec, x10 is already using Varnish caching for all sites? That means I don't need to use a caching plugin for my WordPress install right? I'm actually beating a dead horse here?
     
    • Useful Useful x 1
  9. Dead-i

    Dead-i x10Hosting Support Ninja Community Support

    Messages:
    6,084
    Likes Received:
    364
    Trophy Points:
    83
    Resources on free hosting users' sites are already cached with Varnish, yes. ;)

    Sorry; I was reading back and it looks like I missed your post. By the time I saw your thread, the error message was no longer showing. I checked both Apache and our monitoring system to see if there were any problems.
     
    • Winner Winner x 1

Share This Page