nginx與Elasticsearch結合使用

Elasticsearch是一種先進的,高性能的,可擴展的開源搜索引擎,提供全文搜索和實時分析的結構化和非結構化的數據。

它的特定是可以通過HTTP使用 RESTful API,很容易的融入現有的web架構。因此在高併發的情況下,採用nginx反向代理負載均衡到多臺Elasticsearch 服務器上。

架構圖:

Elasticsearch

這種架構的優點是:

  1. 記錄每個API請求的日誌
  2. 支持大量的客戶端連接,不管有沒有啓用keepalives,比長連接(使用keepalives)到elasticsearch服務器小的多
  3. 負載均衡的請求Elasticsearch服務器
  4. 緩存數據,減少同一內容再次請求Elasticsearch服務器。NGINX Plus 還提供HTTP API 對緩存數據的清除接口
  5. 提供主動健康檢測(僅nginx plus),不斷檢測後端Elasticsearch服務器是否正常,並主動的進行切換。
  6. 報告豐富的監控指標(僅nginx plus),提供監控和管理。
  7. 支持通過HTTP API動態的配置上游服務器組(僅nginx plus),可以從上游服務器組中添加和刪除,上線或下線,改變權重。

Elasticsearch

下表比較Elasticsearch 、Elasticsearch + nginx F/OSS、Elasticsearch + NGINX Plus 的功能:

 

  Elasticsearch client nginx F/OSS NGINX Plus
Horizontal scalability Y Y Y
Keepalive optimization   Y Y
Centralized HTTP access logs   Y Y
Queuing and concurrency control     Y
Response caching   Y Y
Failover of failed connections Y Y Y
Active monitoring of Elasticsearch nodes Y (some clients)   Y
Advanced load balancing methods   Y Y
Weighted load balancing   Y Y
Dynamic reconfiguration     Y
Status monitoring     Y
General-purpose HTTP load balancing   Y Y

當使用NGINX Plus高可用性主動或被動配置負載均衡的Elasticsearch 服務器集羣時,Elasticsearch 客戶端通過nginx plus請求,而不是直接連接到Elasticsearch服務器,可以根據實際情況任意的擴展Elasticsearch服務器不用更新客戶端。

部署NGINX Plus + Elasticsearch

負載均衡、對有效的請求緩存10分鐘、主動的健康監測、狀態收集。

Elasticsearch是一個強大而靈活的搜索引擎,與nginx完美構建成一個可擴展高性能高可用性架構。

更多關於安全性的問題可以參見:

Securing Elasticsearch with Nginx
Playing HTTP Tricks with Nginx

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章