在過去的兩年里,我們一直在開發企業應用程式。基于微服務架構,我們有九個服務及其各自的資料庫和一個在 NGINX 上呼叫/連接微服務的 Angular 前端。在我們的開發程序中,我們在內部網路上使用 4GB RAM 和 2 個 CPU 在 Hetzner 云服務器上實作了這些服務及其資料庫,并且一切都在無縫運行。我們正在 AWS S3 上上傳所有影像、pdf 和視頻,并且進展順利。各種尺寸的視頻都被上傳和播放,沒有任何問題。
我們喜歡 Hetzner,并決定與他們一起制作。我們使用了第一臺服務器并在其上安裝了 proxmox,并部署了 LXC 容器和我們的服務。我這里又測驗了一遍,又沒有發現問題。
然后,我們決定采用另一臺服務器,部署 proxmox,并將它們集群化。當我們聘請了一個在兩個節點的容器之間配置橋接網路的網路人員時,問題就從這里開始了。每個容器都可以 ping 另一個,并且 telnet 也通過內部網路連接。在此網橋上設定的 MTU 為 1400。
主要問題 - 我們無法再從該網路將超過 2 MB 的視頻上傳到 S3
其他問題——這些是間歇性問題,在日志中注明——
NGNIX – 504 Gateway Time-out ERRORS of likes, on multiple services--> upstream timed out (110: Connection timed out) while reading response header from upstream, client: 223.235.101.169, server: abc.xyz.com, request: “GET /courses/course HTTP/1.1”,上游:“http://10.10.XX.XX:8080//courses/course/toBeApprove”,主機:“abc.xyz.com,”,推薦人:“https: // abc.xyz.com, /"
Tomcat- com.amazonaws.services.s3.model.AmazonS3Exception:您與服務器的套接字連接未在超時期限內讀取或寫入。空閑連接將被關閉。(Service: Amazon S3; Status Code: 400; Error Code: RequestTimeout; Request ID: 7J2EHKVDWQP3367G; S3 Extended Request ID: xGGCQhESxh/Mo6ddwtGYShLIeCJYbgCRT8oGleQu/IfguEfbZpTQXG/AIzgLnG2F5YuCqk7vVE8=), S3 Extended Request ID: xGGCQhESxh/Mo6ddwtGYShLIeCJYbgCRT8oGleQu/IfguEfbZpTQXG/AIzgLnG2F5YuCqk7vVE8=
(我們在 nginx 和 tomcat 中增加了所有已知的超時)
- Mysql- 2022-09-08T04:24:27.235964Z 8 [警告] [MY-010055] [服務器] IP地址'10.10.XX.XX無法決議:名稱或服務未知
其他需要注意的關鍵點——我們允許上傳高達 100 mb 的視頻,因此在 nginx 和 tomcat 配置中設定了已知限制
Nginx,client_max_body_size 100m;
和 tomcat <Connector port="8080" protocol="HTTP/1.1" maxPostSize="102400" maxHttpHeaderSize="102400" connectionTimeout="20000" redirectPort="8443" />
在過去 15 天運行的這些讀數和試驗中,我們在除錯時停止了所有防火墻、作業系統上的 ufw、proxmox 防火墻,甚至資料中心防火墻。
這是我們的 nginx.conf
http {
proxy_http_version 1.1;
proxy_set_header Connection "";
##
client_body_buffer_size 16K;
client_header_buffer_size 1k;
client_max_body_size 100m;
client_header_timeout 100s;
client_body_timeout 100s;
large_client_header_buffers 4 16k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 300;
send_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
gzip on;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/x-javascript text/xml text/css application/xml;
這些是我們的主要測驗/除錯試驗。
**1. Testing with a small video (of size 273 Kb)**
a. Nginx log- clean, nothing related to operations
b. Tomcat log-
Start- CoursesServiceImpl - addCourse - Used Memory:73
add course 703
image file not null org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile@15476ca3
image save to s3 bucket
image folder name images
buckets3 lmsdev-cloudfront/images
image s3 bucket for call
imageUrl https://lmsdev-cloudfront.s3.amazonaws.com/images/703_4_istockphoto-1097843576-612x612.jpg
video file not null org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile@13419d27
video save to s3 bucket
video folder name videos
input Stream java.io.ByteArrayInputStream@4da82ff
buckets3 lmsdev-cloudfront/videos
video s3 bucket for call
video url https://lmsdev-cloudfront.s3.amazonaws.com/videos/703_4_giphy360p.mp4
Before Finally - CoursesServiceImpl - addCourse - Used Memory:126
After Finally- CoursesServiceImpl - addCourse - Used Memory:49
c. S3 bucket
[S3 bucket][1]
[1]: https://i.stack.imgur.com/T7daW.png
3. Testing with video 2 mb (fractionally less)
a. Progress bar keeps running about 5 minutes, then
b. Nginx logs-
2022/09/10 16:15:34 [error] 3698306#3698306: *24091 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 223.235.101.169, server: login.pathnam.education, request: "POST /courses/courses/course HTTP/1.1", upstream: "http://10.10.10.10:8080//courses/course", host: "login.pathnam.education", referrer: "https://login.pathnam.education/"
c. Tomcat logs-
Start- CoursesServiceImpl - addCourse - Used Memory:79
add course 704
image file not null org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile@352d57e3
image save to s3 bucket
image folder name images
buckets3 lmsdev-cloudfront/images
image s3 bucket for call
imageUrl https://lmsdev-cloudfront.s3.amazonaws.com/images/704_4_m_Maldives_dest_landscape_l_755_1487.webp
video file not null org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile@45bdb178
video save to s3 bucket
video folder name videos
input Stream java.io.ByteArrayInputStream@3a85dab9
And after few minutes
com.amazonaws.SdkClientException: Unable to execute HTTP request: Connection timed out (Write failed)
d. S3 Bucket – No entry
現在嘗試從我們的測驗服務器上傳相同的視頻,并立即上傳到 S3 存盤桶。
閱讀所有有類似問題的帖子,大多與 php.ini 配置有關,因此與我們無關。
uj5u.com熱心網友回復:
我現在已經解決了這個問題,LXC 容器中設定的 MTU 設定與虛擬交換機中配置的不同。Proxmox 在創建 LXC 容器時不會設定 MTU(并且您希望使用橋 MTU),您可能會錯過這一點。
轉到容器的conf檔案;就我而言,它是 100 nano /etc/pve/lxc/100.conf
找到并編輯這一行 net0: name=eno1,bridge=vmbr4002,firewall=1,hwaddr=0A:14:98:05:8C:C5,ip=192.168.0.2/24,type=veth
添加 mtu 值,按照最后的切換:name=eno1,bridge=vmbr4002,firewall=1,hwaddr=0A:14:98:05:8C:C5,ip=192.168.0.2/24,type=veth ,mtu=1400(我在 vswitch 的價值)
重新啟動容器以進行永久更改。
對我來說,這一切都像是一種魅力。希望它可以幫助那些也使用 Proxmox 介面來創建容器并因此錯過了通過 CLI 配置的人(Proxmox 的建議增強)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/508689.html
