question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

504 Gateway Time-out

See original GitHub issue

Hello, I am crawling a website with 10K contents, when I crawl first it’s all response 200, everything is ok, but after few minutes 504 Gateway Time-out appears and after 3 times retrying scrapy give up retrying. I set :

    'CONCURRENT_REQUESTS':10,
    'HTTPCACHE_ENABLED':True,
    'DOWNLOAD_DELAY':5,
    'CONCURRENT_REQUESTS_PER_IP':10,

and endpoint is render.html

'splash' : {
    'endpoint' : 'render.html',
    'args' : {'wait':1},
}

I am using : *scrapy version: 1.0.3 *python:2.7 *docker server

How can I optimize my crawler ? and avoid 504 error?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
yeszaocommented, Jul 5, 2019

Follow @omkaaa, I change the args to:

yield SplashRequest(url, self.parse, args={'wait': 0.5, 'viewport': '1024x2480', 'timeout':90, 'images': 0}

It works!

Besides, some website would very quick when you using curl or Browser, but very slow in splash, because splash cannot download some resources currectly.

These can also come across with 504 Gateway Time-out. The right way is stop the slow resource download. in Splash, you can set resource_timeout in args:

    def start_requests(self):
        for url in self.start_urls:
            yield SplashRequest(url,
                                self.parse,
                                args={'wait': 0.5, 'viewport': '1024x2480', 'timeout': 90, 'images': 0, 'resource_timeout': 10},
                                )
1reaction
kmikecommented, Nov 25, 2015
Read more comments on GitHub >

github_iconTop Results From Across the Web

504 Gateway Timeout - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 504 Gateway Timeout server error response code indicates that the server, while acting as a gateway ...
Read more >
The Quick & Easy Guide to Fixing 504 Gateway Timeout Errors
A 504 Gateway Timeout Error means your web server didn't receive a timely response from another server upstream when it attempted to load...
Read more >
What is a 504 Gateway Timeout error, and how to fix it?
The 504 (Gateway Timeout) status code indicates that the server while acting as a gateway or proxy, did not receive a timely response...
Read more >
How to Fix 504 Gateway Timeout Error: 10 Reliable Solutions
The 504 “Gateway Timeout” Error indicates that the browser sent an HTTP request to the server and it did not receive a response...
Read more >
How to Fix the 504 Gateway Timeout Error on Your Site - Kinsta
A 504 Gateway Timeout error indicates that the web server is waiting too long to respond from another server and “timing out.” There...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found