Java EE servlet 的(内存)占用量是多少?
对于 Jetty、Tomcat 或您选择的任何其他 servlet 容器,基本 servlet 的平均占用空间(内存和任何其他显着资源)是多少?这包括每个 servlet 几乎总是需要的任何其他基本对象,例如视图解析器。
我并不是在寻找具体的定量数字,而是在寻找任何可以说明 servlet 的“重度”或“轻量级”程度的指示性答案。
For Jetty, Tomcat, or any other servlet container of your choice, what's the average footprint (memory, and any other notable resources) of a basic servlet? This includes any other basic objects that you almost always need per servlet, such as a view resolver.
I'm not looking for a quantitative number in particular, but any indicative answer that could give an idea of how "heavy" or "lightweight" a servlet is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为在 Stack Overflow 上提问不会给你带来多大好处。 “基本”定义的可变性以及 servlet 软件的不同版本将比您自己测试所需的工作量大得多。
只需创建一个没有字段的“hello-world”类型 servlet,使用此 WAR 启动您选择的 servlet 容器并测量内存使用情况。这将大致为您提供 servlet 容器的开销,然后您可以在查看目标 servlet 的“重量级”时从实际内存测量中减去该开销。
如果您使用实际系统上 servlet 容器的实际目标版本生成这些数字,那么这些数字将比在这里回复的人说“47MB”或类似的数字有用得多。
I don't think this is something that you're getting much benefit from asking on Stack Overflow. The variability in the definition of "basic", and the different versions of servlet software, are going to be much greater than the amount of effort required to test this yourself.
Simply create a "hello-world" type servlet that has no fields, fire up your servlet container(s) of choice with this WAR and measure memory usage. This will broadly give you the overhead of the servlet container, which you can then subtract from your actual memory measurements when seeing how "heavyweight" the target servlet is.
The numbers will be much more useful if you generate themselves using the actual target version of the servlet container on the actual system in question, than someone replying here saying "47MB" or similar.
容器大小非常无关紧要(Tomcat 或 Jetty,而不是 Websphere 或类似的东西),除非您正在进行嵌入式编程。 Servlet 的大小可以根据您的需要而小,也可以根据您的需要而大。一般来说,无状态 Web 应用程序每个线程的开销比有状态 Web 应用程序要少。
The container size is pretty irrelevant (Tomcat or Jetty, not Websphere or anything like that) unless you're doing embedded programming. The Servlet size can be as small as you need it or as large as you need it. Generally speaking, stateless web applications will have less overhead per thread than stateful ones.