504 - nginx + fastcgi + Django 经常504

【字号: 日期:2022-06-29浏览:40作者:雯心

问题描述

网站访问量非常小,之前有段时间是每周末结束回来就会出现 504错误,重启fastcgi 就OK,后来频率变得越来越高,从一周变成一天,到半天,但是中间代码没有什么大的变动,感觉很奇怪。在服务器上运行 netstat 命令得到的结果如下 :不知道大家遇到这类问题是一般是怎么去调试呢?还有Active UNIX domain sockets (w/o servers)这个下面这对东西有没有问题?

$ netstatActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address Foreign Address State tcp0 0 localhost:9099 localhost:45614 SYN_RECV tcp0 0 localhost:9099 localhost:45615 SYN_RECV tcp0 0 localhost:9099 localhost:45613 SYN_RECV tcp0 0 localhost:9099 localhost:45612 SYN_RECV tcp0 0 localhost:9099 localhost:45616 SYN_RECV tcp 513 0 localhost:9099 localhost:44474 CLOSE_WAIT tcp 465 0 localhost:9099 localhost:44375 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44423 CLOSE_WAIT tcp 457 0 localhost:9099 localhost:44365 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44517 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44346 CLOSE_WAIT tcp 689 0 localhost:9099 localhost:44378 CLOSE_WAIT tcp0 521 localhost:45614 localhost:9099 FIN_WAIT1 tcp 505 0 localhost:9099 localhost:44399 CLOSE_WAIT tcp0 561 localhost:45615 localhost:9099 FIN_WAIT1 tcp 625 0 localhost:9099 localhost:44337 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44402 CLOSE_WAIT tcp 561 0 localhost:9099 localhost:44425 CLOSE_WAIT tcp 673 0 localhost:9099 localhost:44409 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44416 CLOSE_WAIT tcp 625 0 localhost:9099 localhost:44508 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44433 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44442 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44405 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44341 CLOSE_WAIT tcp 657 0 localhost:9099 localhost:44503 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44336 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44489 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44382 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44397 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44370 CLOSE_WAIT tcp 521 0 localhost:9099 localhost:44521 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44340 CLOSE_WAIT tcp 521 0 localhost:9099 localhost:44494 CLOSE_WAIT tcp 441 0 localhost:9099 localhost:44478 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44391 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44495 CLOSE_WAIT tcp 521 0 localhost:9099 localhost:44332 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44473 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44470 CLOSE_WAIT tcp 689 0 localhost:9099 localhost:44468 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44424 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44447 CLOSE_WAIT tcp 473 0 localhost:9099 localhost:44361 CLOSE_WAIT tcp 473 0 localhost:9099 localhost:44484 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44412 CLOSE_WAIT tcp 625 0 localhost:9099 localhost:44383 CLOSE_WAIT tcp 625 0 localhost:9099 localhost:44355 CLOSE_WAIT tcp 473 0 localhost:9099 localhost:44481 CLOSE_WAIT tcp 689 0 localhost:9099 localhost:44446 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44394 CLOSE_WAIT tcp 489 0 localhost:9099 localhost:44324 CLOSE_WAIT tcp 545 0 localhost:9099 localhost:44400 CLOSE_WAIT tcp 481 0 localhost:9099 localhost:44487 CLOSE_WAIT tcp 625 0 localhost:9099 localhost:44418 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44457 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44438 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44502 CLOSE_WAIT tcp 681 0 localhost:9099 localhost:44344 CLOSE_WAIT tcp 465 0 localhost:9099 localhost:44486 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44323 CLOSE_WAIT tcp 465 0 localhost:9099 localhost:44362 CLOSE_WAIT tcp 689 0 localhost:9099 localhost:44327 CLOSE_WAIT tcp 457 0 localhost:9099 localhost:44522 CLOSE_WAIT tcp 521 0 localhost:9099 localhost:44513 CLOSE_WAIT tcp 569 0 localhost:9099 localhost:44458 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44437 CLOSE_WAIT tcp 569 0 localhost:9099 localhost:pmcd CLOSE_WAIT tcp 489 0 localhost:9099 localhost:44462 CLOSE_WAIT tcp 569 0 localhost:9099 localhost:44328 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44485 CLOSE_WAIT tcp 689 0 localhost:9099 localhost:44430 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44434 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44453 CLOSE_WAIT tcp 481 0 localhost:9099 localhost:44519 CLOSE_WAIT tcp 465 0 localhost:9099 localhost:44480 CLOSE_WAIT tcp 681 0 localhost:9099 localhost:44401 CLOSE_WAIT tcp 689 0 localhost:9099 localhost:44334 CLOSE_WAIT tcp 481 0 localhost:9099 localhost:44482 CLOSE_WAIT tcp 673 0 localhost:9099 localhost:44455 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44428 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44518 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:pmcdproxy CLOSE_WAIT tcp 489 0 localhost:9099 localhost:44498 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44467 CLOSE_WAIT tcp 433 0 localhost:9099 localhost:44477 CLOSE_WAIT tcp 457 0 localhost:9099 localhost:44363 CLOSE_WAIT tcp 681 0 localhost:9099 localhost:44451 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44385 CLOSE_WAIT tcp0 0 xx.xx.xx.xx:httpcrawl-66-249-76-235.g:36350 ESTABLISHED tcp 473 0 localhost:9099 localhost:44358 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44444 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44353 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44325 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44377 CLOSE_WAIT tcp 673 0 localhost:9099 localhost:44501 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44499 CLOSE_WAIT tcp0 0 xx.xx.xx.xx:ssh 114.248.169.70:56609ESTABLISHED tcp 689 0 localhost:9099 localhost:44516 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44364 CLOSE_WAIT tcp 465 0 localhost:9099 localhost:44359 CLOSE_WAIT tcp0 0 xx.xx.xx.xx:ssh 114.248.169.70:57441ESTABLISHED tcp 521 0 localhost:9099 localhost:44415 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44395 CLOSE_WAIT tcp 521 0 localhost:9099 localhost:44411 CLOSE_WAIT tcp 465 0 localhost:9099 localhost:44360 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44413 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44406 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44356 CLOSE_WAIT tcp 905 0 localhost:9099 localhost:44440 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44465 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44510 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44347 CLOSE_WAIT tcp 521 0 localhost:9099 localhost:44372 CLOSE_WAIT tcp 625 0 localhost:9099 localhost:44366 CLOSE_WAIT tcp 489 0 localhost:9099 localhost:44338 CLOSE_WAIT tcp 465 0 localhost:9099 localhost:44483 CLOSE_WAIT tcp 905 0 localhost:9099 localhost:44436 CLOSE_WAIT tcp 449 0 localhost:9099 localhost:44379 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44393 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44403 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44371 CLOSE_WAIT tcp 513 0 localhost:9099 localhost:44374 CLOSE_WAIT tcp 505 0 localhost:9099 localhost:44333 CLOSE_WAIT tcp 625 0 localhost:9099 localhost:44461 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44449 CLOSE_WAIT tcp 681 0 localhost:9099 localhost:44497 CLOSE_WAIT tcp 905 0 localhost:9099 localhost:44476 CLOSE_WAIT tcp 689 0 localhost:9099 localhost:44491 CLOSE_WAIT tcp0 520 localhost:45616 localhost:9099 ESTABLISHED tcp 513 0 localhost:9099 localhost:44504 CLOSE_WAIT tcp 689 0 localhost:9099 localhost:44384 CLOSE_WAIT tcp 441 0 localhost:9099 localhost:44512 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44479 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44427 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44414 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44432 CLOSE_WAIT tcp 497 0 localhost:9099 localhost:44463 CLOSE_WAIT tcp 673 0 localhost:9099 localhost:44352 CLOSE_WAIT tcp 633 0 localhost:9099 localhost:44396 CLOSE_WAIT tcp0 4860 xx.xx.xx.xx:ssh 123.120.30.5:38913 ESTABLISHED Active UNIX domain sockets (w/o servers)Proto RefCnt Flags Type State I-Node Pathunix 2 [ ] DGRAM 609897 @/org/kernel/udev/udevdunix 2 [ ] DGRAM 16202 @/org/freedesktop/hal/udev_eventunix 16 [ ] DGRAM 628931 /dev/logunix 3 [ ] STREAM CONNECTED 31371466 unix 3 [ ] STREAM CONNECTED 31371465 unix 2 [ ] DGRAM 31371462 unix 2 [ ] DGRAM 31368809 unix 2 [ ] UNKNOWN DISCONNECTING 0 unix 2 [ ] STREAM 31356911 unix 2 [ ] DGRAM 31356908 unix 2 [ ] UNKNOWN DISCONNECTING 0 unix 2 [ ] STREAM 31342249 unix 2 [ ] DGRAM 31342246 unix 2 [ ] UNKNOWN DISCONNECTING 0 unix 2 [ ] STREAM 31318762 unix 2 [ ] DGRAM 31318761 unix 2 [ ] UNKNOWN DISCONNECTING 0 unix 2 [ ] STREAM 31263304 unix 2 [ ] DGRAM 31263300 unix 3 [ ] STREAM CONNECTED 31253401 unix 3 [ ] STREAM CONNECTED 31253400 unix 3 [ ] STREAM CONNECTED 31253399 unix 3 [ ] STREAM CONNECTED 31253398 unix 3 [ ] STREAM CONNECTED 31253397 unix 3 [ ] STREAM CONNECTED 31253396 unix 3 [ ] STREAM CONNECTED 31253395 unix 3 [ ] STREAM CONNECTED 31253394 unix 2 [ ] STREAM CONNECTED 31253390 unix 3 [ ] STREAM CONNECTED 31253287 unix 3 [ ] STREAM CONNECTED 31253286 unix 2 [ ] DGRAM 31253283 unix 3 [ ] STREAM CONNECTED 31247947 unix 3 [ ] STREAM CONNECTED 31247946 unix 3 [ ] STREAM CONNECTED 31247945 unix 3 [ ] STREAM CONNECTED 31247944 unix 3 [ ] STREAM CONNECTED 31247943 unix 3 [ ] STREAM CONNECTED 31247942 unix 3 [ ] STREAM CONNECTED 31247941 unix 3 [ ] STREAM CONNECTED 31247940 unix 2 [ ] STREAM CONNECTED 31247936 unix 3 [ ] STREAM CONNECTED 31178429 unix 3 [ ] STREAM CONNECTED 31178428 unix 3 [ ] STREAM CONNECTED 31171939 unix 3 [ ] STREAM CONNECTED 31171938 unix 2 [ ] DGRAM 31171935 unix 3 [ ] STREAM CONNECTED 27227510 unix 3 [ ] STREAM CONNECTED 27227509 unix 3 [ ] STREAM CONNECTED 27227508 unix 3 [ ] STREAM CONNECTED 27227507 unix 3 [ ] STREAM CONNECTED 27227506 unix 3 [ ] STREAM CONNECTED 27227505 unix 3 [ ] STREAM CONNECTED 27227504 unix 3 [ ] STREAM CONNECTED 27227503 unix 3 [ ] STREAM CONNECTED 27227502 unix 3 [ ] STREAM CONNECTED 27227501 unix 3 [ ] STREAM CONNECTED 27227500 unix 3 [ ] STREAM CONNECTED 27227499 unix 3 [ ] STREAM CONNECTED 27227498 unix 3 [ ] STREAM CONNECTED 27227497 unix 3 [ ] STREAM CONNECTED 27227496 unix 3 [ ] STREAM CONNECTED 27227495 unix 3 [ ] STREAM CONNECTED 27227494 unix 3 [ ] STREAM CONNECTED 27227493 unix 3 [ ] STREAM CONNECTED 27227492 unix 3 [ ] STREAM CONNECTED 27227491 unix 2 [ ] STREAM CONNECTED 27227487 unix 2 [ ] DGRAM 24840891 unix 2 [ ] DGRAM 24840814 unix 2 [ ] DGRAM 24834624 unix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 2 [ ] STREAM CONNECTING 0 /var/run/abrt/abrt.socketunix 3 [ ] STREAM CONNECTED 1131884 unix 3 [ ] STREAM CONNECTED 1131883 unix 3 [ ] STREAM CONNECTED 1131882 unix 3 [ ] STREAM CONNECTED 1131881 unix 3 [ ] STREAM CONNECTED 1131880 unix 3 [ ] STREAM CONNECTED 1131879 unix 3 [ ] STREAM CONNECTED 1131878 unix 3 [ ] STREAM CONNECTED 1131877 unix 2 [ ] STREAM CONNECTED 1131873 unix 2 [ ] DGRAM 1088807 unix 2 [ ] DGRAM 631192 unix 2 [ ] DGRAM 629682 unix 2 [ ] DGRAM 625326 unix 2 [ ] DGRAM 616785 unix 3 [ ] DGRAM 609927 unix 3 [ ] DGRAM 609926 unix 3 [ ] STREAM CONNECTED 17181 unix 3 [ ] STREAM CONNECTED 17180 unix 3 [ ] STREAM CONNECTED 17177 unix 3 [ ] STREAM CONNECTED 17176 unix 3 [ ] STREAM CONNECTED 17173 unix 3 [ ] STREAM CONNECTED 17172 unix 3 [ ] STREAM CONNECTED 17168 unix 3 [ ] STREAM CONNECTED 17167 unix 3 [ ] STREAM CONNECTED 17164 unix 3 [ ] STREAM CONNECTED 17163 unix 3 [ ] STREAM CONNECTED 17160 unix 3 [ ] STREAM CONNECTED 17159 unix 3 [ ] STREAM CONNECTED 17155 unix 3 [ ] STREAM CONNECTED 17154 unix 3 [ ] STREAM CONNECTED 17151 unix 3 [ ] STREAM CONNECTED 17150 unix 3 [ ] STREAM CONNECTED 17147 unix 3 [ ] STREAM CONNECTED 17145 unix 3 [ ] STREAM CONNECTED 17142 unix 3 [ ] STREAM CONNECTED 17141 unix 3 [ ] STREAM CONNECTED 17138 unix 3 [ ] STREAM CONNECTED 17137 unix 3 [ ] STREAM CONNECTED 17134 unix 3 [ ] STREAM CONNECTED 17133 unix 3 [ ] STREAM CONNECTED 17130 unix 3 [ ] STREAM CONNECTED 17129 unix 3 [ ] STREAM CONNECTED 17126 unix 3 [ ] STREAM CONNECTED 17125 unix 3 [ ] STREAM CONNECTED 17122 unix 3 [ ] STREAM CONNECTED 17121 unix 3 [ ] STREAM CONNECTED 17118 unix 3 [ ] STREAM CONNECTED 17117 unix 3 [ ] STREAM CONNECTED 17114 unix 3 [ ] STREAM CONNECTED 17113 unix 3 [ ] STREAM CONNECTED 17110 unix 3 [ ] STREAM CONNECTED 17109 unix 3 [ ] STREAM CONNECTED 17106 unix 3 [ ] STREAM CONNECTED 17105 unix 3 [ ] STREAM CONNECTED 17102 unix 3 [ ] STREAM CONNECTED 17101 unix 3 [ ] STREAM CONNECTED 17098 unix 3 [ ] STREAM CONNECTED 17097 unix 3 [ ] STREAM CONNECTED 17094 unix 3 [ ] STREAM CONNECTED 17093 unix 3 [ ] STREAM CONNECTED 17090 unix 3 [ ] STREAM CONNECTED 17089 unix 3 [ ] STREAM CONNECTED 17087 unix 3 [ ] STREAM CONNECTED 17086 unix 2 [ ] DGRAM 17036 unix 3 [ ] STREAM CONNECTED 16423 /var/run/acpid.socketunix 3 [ ] STREAM CONNECTED 16422 unix 3 [ ] STREAM CONNECTED 16417 @/var/run/hald/dbus-PLTrnFGoYaunix 3 [ ] STREAM CONNECTED 16416 unix 3 [ ] STREAM CONNECTED 16378 @/var/run/hald/dbus-PLTrnFGoYaunix 3 [ ] STREAM CONNECTED 16297 unix 3 [ ] STREAM CONNECTED 16197 @/var/run/hald/dbus-YyLOb5j6TMunix 3 [ ] STREAM CONNECTED 16196 unix 3 [ ] STREAM CONNECTED 16175 /var/run/dbus/system_bus_socketunix 3 [ ] STREAM CONNECTED 16174 unix 2 [ ] DGRAM 16141 unix 3 [ ] STREAM CONNECTED 16021 /var/run/dbus/system_bus_socketunix 3 [ ] STREAM CONNECTED 16020 unix 3 [ ] STREAM CONNECTED 16015 unix 3 [ ] STREAM CONNECTED 16014 unix 3 [ ] STREAM CONNECTED 13036 unix 3 [ ] STREAM CONNECTED 13035

问题解答

回答1:

出现504错误的话。主要主要后面实体服务请求时间估计是要比较大的时间。其实这个可以在你的nginx中加入几个参数试一下。使用fastcgi或是反向代理proxy加入超时时间。还有就是client_header_timeout,client_body_timeout,send_timeout.

相关文章: