nginx 可以用于前端分片、基于 HTTP 的资源吗?
信息
CouchDB 是一个 RESTful、基于 HTTP 的 NoSQL 数据存储。响应以简单的 JSON 形式发回,并且能够利用 ETag生成的响应可帮助缓存服务器判断数据是否已更改。
问题
是否可以使用nginx来管理CouchDB服务器的集合,其中每个Couch服务器都是一个更大集合的分片(而不是彼此的副本),并让它根据查询字符串的特定方面?
示例查询:
http://db.mysite.com?id=1
http://db.mysite.com?id=2
分片逻辑:
shard = ${id} % 2; // even/odd
这不是一个直接的“负载平衡”问题,因为我需要相同的请求始终在相同的服务器上结束,但我很好奇这种类型的简单路由逻辑是否可以写入nginx 站点配置。
如果可以的话,这个解决方案如此有吸引力的原因是您可以打开 nginx 缓存来自 Couch 服务器的 JSON 响应,并以非常强大且可扩展的方式很好地打包和部署整个设置。
Info
CouchDB is a RESTful, HTTP-based NoSQL datastore. Responses are sent back in simple JSON and it is capable of utilizing ETags in the generated responses to help caching servers tell if data has changed or not.
Question
Is it possible to use nginx to front a collection of CouchDB servers where each Couch server is a shard of a larger collection (and not replicas of each other) and have it determine the target shard based on a particular aspect of the query string?
Example Queries:
http://db.mysite.com?id=1
http://db.mysite.com?id=2
Shard Logic:
shard = ${id} % 2; // even/odd
This isn't a straight forward "load balancing" question because I would need the same requests to always end up at the same servers, but I am curious if this type of simple routing logic can be written into an nginx site configuration.
If it can be, what makes this solution so attractive is that you can then turn on nginx caching of the JSON responses from the Couch servers and have the entire setup nicely packaged up and deployed in a very capable and scalable manner.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以拼凑一些东西,也可以使用 BigCouch (https://github.com/cloudant/bigcouch)。
You could cobble something together or you could use BigCouch (https://github.com/cloudant/bigcouch).