可靠的数据服务 [英] Reliable data serving

查看:114
本文介绍了可靠的数据服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确保我的文件服务可靠且可扩展?它可以处理多少个并行请求?

How can i make sure my file serving is reliable and scalable? How many parallel request it can handle?

我在想硬件功能和带宽。

I am thinking beyond the hardware capability and band width.

我跟随在java servlet中流式传输大型文件

推荐答案

如果这些是静态文件,只需直接链接到 即可。所有体面的servletcontainers / appservers都有一个发展良好的 DefaultServlet 。如果这些是位于外部的外部的静态文件,那么您可以将这些文件的根文件夹添加到另一个上下文中。目前还不清楚你正在使用哪个服务器,但如果它是Tomcat,你可以在 server.xml中添加一个新的< Context>

If those are static files, just link to it directly. All decent servletcontainers/appservers have a well-developed DefaultServlet. If those are static files located outside the webapplication from where you'd link them to, then you can also just add the root folder of those files as another context. It's unclear which server you're using, but if it were Tomcat, you could just add a new <Context> to server.xml:

<Context docBase="/path/to/static/files" path="/files" />

这种方式可以通过 http://example.com/files/访问...

如果这些是动态生成的文件或来自数据库的文件,那么你需要开发一个用于执行IO的servlet高效工作:即在发出之前不要将整个数据不必要地存储在内存中(例如,在 ByteArrayInputStream byte [] 中将它们输出到输出。只需将立即字节写入输出。你可能会发现这些基本文件服务器和更多高级文件服务器(支持简历等)很有用。

If those are dynamically generated files or files coming from a database, then you need to develop a servlet which does the IO job efficiently: i.e. do not unnecessarily store the entire data in memory (e.g. in a ByteArrayInputStream or byte[] before emitting them to the output. Just write the bytes immediately to the output as it comes in. You may find this those examples of a basic fileservlet and a more advanced fileservlet (supporting resumes and so on) useful.

这篇关于可靠的数据服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆