用于静态内容的轻量级 HTTP 应用程序/服务器
我需要一个可扩展且高性能的 HTTP 应用程序/服务器,用于静态文件服务/上传。所以我只需要支持 GET
和 PUT
操作。
但是,我需要一些额外的功能:
- 自定义身份验证:我需要 针对每个请求检查数据库的凭据。 因此我必须能够整合专有 数据库交互。
- 支持 签名访问密钥:访问 应对通过
PUT
的资源进行签名 使用像 http://uri/?key=foo 这样的密钥 然后该密钥包含有关请求的信息,例如 md5(user + path +秘密),这允许我阻止不需要的请求。应用程序/服务器应该允许我检查这一点。 - 性能:我想尽可能避免管道内容。否则整个应用程序可以用 Perl/etc 来实现。几行CGI。
Perlbal(在网络服务器模式下)看起来不错,但是单线程模型不适合我的数据库查找,而且也不支持查询字符串。
Lighttp/Nginx/… 有一些用于这些任务的模块,但是如果不编写自己的扩展/模块,将所有内容放在一起是不可行的。
那么你会如何解决这个问题呢?还有其他轻量级网络服务器可用于此吗? 我应该在网络服务器(即 CGI)内实现应用程序吗?如何避免/加速网络服务器和我的应用程序之间的管道内容。
提前致谢!
I am in need of a scalable and performant HTTP application/server that will be used for static file serving/uploading. So I only need support for GET
and PUT
operations.
However, there are a few extra features that I need:
- Custom authentication: I need to
check credentials against a database for each request.
Thus I must be able to integrate propietary
database interaction. - Support for
signed access keys: The access to
resources viaPUT
should be signed
using a key like http://uri/?key=foo The key then contains information about the request like md5(user + path + secret) which allows me to block unwanted requests. The application/server should allow me to check for this. - Performance: I'd like to avoid piping content as much as possible. Otherwise the whole application could be implemented in Perl/etc. in a few lines as CGI.
Perlbal (in webserver mode) looks nice, however the single-threaded model does not fit with my database lookup and it does also not support query strings.
Lighttp/Nginx/… have some modules for these tasks, however it is not feasible putting everything together without ending up writing own extensions/modules.
So how would you solve this? Are there other leightweight webservers available for this?
Should I implement an application inside of a webserver (i.e. CGI). How can I avoid/speed up piping content between the webserver and my application.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看nodejs http://nodejs.org/
有一些静态Web服务器和数据库接口的模块:
http://wiki.github.com/ry/node/modules
你可能有编写您自己的文件上传处理程序,或使用此示例中的一个 http://www.componentix.com/博客/13
Have a look at nodejs http://nodejs.org/
There are a few modules for static web servers and database interfaces:
http://wiki.github.com/ry/node/modules
You might have to write your own file upload handler, or use one from this example http://www.componentix.com/blog/13
用 C + memcached + sqlite 编写的 nginx + spawn-fcgi + fcgi 应用程序可以很好地完成类似的任务,对于来自同一本地网络的小数据和快速连接,延迟约为 20-30 毫秒。据我所知,生产服务器每秒处理大约 100-150 个请求没有问题。在测试服务器上,我的峰值达到每秒 20k 请求,同样没有问题,平均延迟约为 60 毫秒。积极的缓存和 UNIX 域套接字是关键。
不知道该配置在频繁的
PUT
请求上的表现如何,在我们的任务中,它们非常罕见并且通常是批处理的。nginx + spawn-fcgi + fcgi application written in C + memcached + sqlite serves for similar task well, latency is about 20-30 ms for small data and fast connections from the same local network. As far as I know production server handles about 100-150 requests per second with no problem. On test server I peaked up to 20k requests per second, again with no problem, average latency were about 60 ms. Aggressive caching and UNIX domain sockets is the key.
Do not know how that configuration will behave on frequent
PUT
requests, in our task they are very rare and typically batched.