在高配置服務器,單個RGW的併發量沒法充分使用機器的網絡帶寬資源,本文用於說明如何在單機上部署多RGW的方法。前端
Ceph官網說明了如何使用Apache做爲前端Web服務器,後官方又退出Civetweb做爲自帶的web服務器。不過考慮實際併發性能,咱們採用Nginx做爲前端web服務器,和radosgw聯合使用。nginx
server { listen 80 default; #server_name .com .com.cn .net .cn .org .tv .cc .hk .tw; server_name ceph-21; location / { fastcgi_pass_header Authorization; fastcgi_pass_request_headers on; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param CONTENT_LENGTH $content_length; if ($request_method = PUT) { rewrite ^ /PUT$request_uri; } include fastcgi_params; fastcgi_pass unix:/var/run/ceph/ceph.radosgw.gateway1.sock; } location /PUT/ { internal; fastcgi_pass_header Authorization; fastcgi_pass_request_headers on; include fastcgi_params; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param CONTENT_TYPE $content_type; fastcgi_pass unix:/var/run/ceph/ceph.radosgw.gateway1.sock; } }
這邊須要詳細注意的是 fastcgi_pass 參數,注意配置gateway.sock。在參數須要和ceph.conf一一對應。在下文中的rgw配置中,rgw_socket_path 須要與 nginx fastcgi_pass一致,從而能夠使得兩個進程基於fastcgi進行通訊。web
[client.radosgw.gateway1] host = ceph-21 rgw frontends = fastcgi log file = /var/log/radosgw/client.radosgw.gateway1.log keyring = /etc/ceph/ceph.client.radosgw.keyring rgw_socket_path = /var/run/ceph/ceph.radosgw.gateway1.sock
Nginx0採用upstream進行負載均衡網絡
upstream nginx-upstream-rgw{ #ip_hash; server 10.71.21.31:81; server 10.71.21.31:82; server 10.71.21.31:83; server 10.71.21.31:84; server 10.71.21.31:85; } server { listen 80 default; server_name demo.ceph.work; location / { proxy_pass http://nginx-upstream-rgw; } }
負載均衡參考文檔併發
每一個Nginx對應一個rgw,對應的配置方法參考章節1。負載均衡
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx1.conf /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx2.conf /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx3.conf /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx4.conf /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx5.conf
radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway1 radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway2 radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway3 radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway4 radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway5
我對上述結構進行了測試,libs3的read, write, list等操做能夠正常訪問,後續進一步測試併發能力。 在相同配置下,原來單RGW測試500K併發是200; 如今採用10個實例,如今併發 > 2000. 仍是要加強單rgw的併發能力。搞這個多實例也不是個事~~~frontend
在該種模式下,RGW會表現出不穩定的狀況,主要體如今當壓力過載時,即使中止壓力測試,一段時間後再訪問,NGINX會爆大量的502錯誤。我會進一步跟進這個錯誤。socket