可靠的数据服务

发布于 2024-08-07 05:35:23 字数 195 浏览 1 评论 0原文

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

我正在思考超越硬件能力和带宽的问题。

我正在关注在java servlet中流式传输大文件

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.

i am following Streaming large files in a java servlet

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

毁梦 2024-08-14 05:35:23

如果这些是静态文件,只需直接链接即可。所有像样的 servlet 容器/应用程序服务器都有一个完善的 DefaultServlet。如果这些静态文件位于您将它们链接到的 Web 应用程序外部,那么您也可以将这些文件的根文件夹添加为另一个上下文。目前尚不清楚您正在使用哪个服务器,但如果它是 Tomcat,您只需将新的 添加到 server.xml 即可:

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

这样就可以通过 <代码>http://example.com/files/...。

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

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" />

This way it's accessible by http://example.com/files/....

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.

护你周全 2024-08-14 05:35:23

如果您只是从文件系统提供静态文件,只需使用 Apache - 它会比您自己编写的任何内容更好。

If you are just serving static files from a file system just use Apache - it's going to be better then anything you will write yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文