需求
使用 Redis 分布式鎖解決高并發下的小視頻上傳
1、前端頁面自行設計
2、Redis + FastDFS
3、功能流程不報錯
視頻講解
BiliBili 鏈接
編程題:Redis + FastDFS 小視頻上傳
說明
使用了 nginx 做負載均衡以及配置 FastDFS 服務器:
upstream renda {
server 192.168.1.116:8001;
server 192.168.1.116:8002;
}
server {
listen 80;
server_name www.videouploadtest.com;
# set client body size to 10M
client_max_body_size 10M;
location / {
proxy_pass http://renda;
index index.html index.htm;
}
}
server {
listen 80;
server_name www.fdfsstorage.com;
location /group1/M00 {
root /home/fastdfs/fdfs_storage/data;
ngx_fastdfs_module;
}
}
使用了 SwitchHosts 編輯本地 host 地址:
# video upload hw
192.168.186.128 www.videouploadtest.com # 上傳視頻業務
192.168.186.128 www.fdfsstorage.com # FastDFS 小視頻存盤倉庫
重啟 Nginx:
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
啟動 FastDFS 的 tracker:
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
啟動 FastDFS 的 storage:
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
啟動 Redis:
/usr/local/bin/redis-server /opt/redis-5.0.4/redis.conf
啟動兩次工程代碼,埠號分別為 8001 和 8002,
使用 JMeter 模擬 1 秒內發出 10 個 http 請求,
執行下面命令可以在服務器中查看上傳的視頻檔案:
cd /home/fastdfs/fdfs_storage/data/00/00/
ll
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/190000.html
標籤:其他
