简体   繁体   English

GlassFish 4.1慢速本地主机Servlet响应(NetBeans)

[英]GlassFish 4.1 Slow Localhost Servlet Response (NetBeans)

I have Netbeans 8.0.2 installed on Ubuntu 15.04 which includes the GlassFish 4.1 EE Container. 我在Ubuntu 15.04上安装了Netbeans 8.0.2,其中包括GlassFish 4.1 EE容器。

For some reason, after ensuring my resolv.conf and hosts files were set-up properly, accessing dynamic content, such as a servlet that pulls data from a SQL database, is terribly slow. 由于某种原因,在确保正确设置了我的resolv.confhosts文件之后,访问动态内容(例如从SQL数据库中提取数据的servlet访问速度非常慢。

However, accessing static JSP pages returns in less than 1ms as it should. 但是,访问静态JSP页面将在不到1ms的时间内返回。

Pinging the server on 127.0.0.1 or localhost returns in 0.038ms or less, which is to be expected, so I don't think the DNS resolving issues common with Linux and localhost are to blame here. 在127.0.0.1或localhost上对服务器执行ping操作将在0.038ms或更短时间内返回,这是可以预期的,因此,我不认为Linux和localhost常见的DNS解析问题应归咎于此。

For kicks, I downloaded the GlassFish 4.1 server off their website and set-up NetBeans to deploy there, and I got the same results. 值得一提的是,我从他们的网站上下载了GlassFish 4.1服务器,并设置了NetBeans进行部署,得到了相同的结果。 In addition I also tried manually deploying my WAR files, and that also resulted in terribly slow response times from dynamic content / servlets. 另外,我还尝试手动部署WAR文件,这也导致动态内容/ Servlet的响应时间非常慢。

What gets me is that with the exact same set-up and configurations, I do not have this issues on Windows. 我得到的是,使用完全相同的设置和配置,我在Windows上没有此问题。

So in summary: 因此,总而言之:

  • Static content resolves and responds in less than 1ms. 静态内容的解析和响应时间不到1ms。
  • Dynamic content through servlets is terribly slow, up to 5 minutes. 通过servlet的动态内容非常慢,最多5分钟。

I did look and see if it was my code. 我确实看了看是否是我的代码。 And no, it is not. 不,不是。 It runs perfectly fine on Windows and Windows Server. 它可以在Windows和Windows Server上完美运行。 It even runs fine when the server is on CentOS and pointing outwards, ie you would browse to a URL and not through the localhost. 当服务器位于CentOS上并指向外部时,它甚至可以正常运行,即您将浏览到URL,而不是通过本地主机。


To clarify, this problem occurs even on servlets that do not access any external resources, such as a servlet that only adds a few lines of HTML, or forwards the request to a static JSP page. 为了澄清,即使在不访问任何外部资源的servlet上也会发生此问题,例如仅添加几行HTML或将请求转发到静态JSP页面的servlet。

Well, 好,

After some extensive digging and profiling, I found the solution: 经过大量的挖掘和分析,我找到了解决方案:

I had a filter that would authenticate users, and set a cookie that changes for every request (prevents CSRF) but used a Java Utils SecureRandom to inject a secure random bit of info into a MD5 hashing algorithm along with some other goodies to spit out a decently secure, one-time use cookie. 我有一个可以对用户进行身份验证的过滤器,并设置了一个针对每个请求而更改的cookie(防止CSRF),但使用了Java Utils SecureRandom将安全的随机信息注入MD5哈希算法中,以及其他一些东西,以吐出相当安全的一次性Cookie。

Apparently, the version of CentOS my production server is using already includes the haveged daemon which keeps the /dev/random entropy topped up. 显然,我的生产服务器使用的CentOS版本已经包含了haveged守护进程,该守护进程使/ dev / random熵保持最高状态。

The issue is that SecureRandom on Linux requests the /dev/random and is blocking. 问题是Linux上的SecureRandom请求/ dev / random并被阻止。 When there isn't enough entropy, it can wait up to 25 seconds before returning. 如果没有足够的熵,它最多可能需要等待25秒才能返回。

Solution was to of course: install the haveged daemon. 解决方案当然是:安装haveged守护程序。 Problem solved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Netbeans 8.0.2 + Glassfish服务器4.1 - Netbeans 8.0.2 + Glassfish server 4.1 筛选器Servlet无法与NetBeans中的glassfish一起使用 - Filter servlet not working with glassfish in netbeans Glassfish Netbeans附加到localhost“连接被拒绝” - Glassfish Netbeans Attaching to localhost “Connection refused” 无法从Netbeans 8.0.1服务区域启动GlassFish 4.1 - Cannot start GlassFish 4.1 from within Netbeans 8.0.1 Service area 为什么glassfish 4.1在netbeans 8.0中运行但在Eclipse luna中却没有 - why glassfish 4.1 runs in netbeans 8.0 but in eclipse luna does not 在使用GlassFish 4.1安装NetBeans 8.0.2之后,无法连接到示例数据库 - After Installing NetBeans 8.0.2 with GlassFish 4.1 Cannot Connect to sample Database 无法在Eclipse Luna上使用Glassfish 4.1服务器的localhost版本 - Can't use localhost version of glassfish 4.1 server on eclipse Luna Java servlet 在 Windows 10、NetBeans 和 Glassfish 中写入文本文件 - Java servlet to write text file in Windows 10, NetBeans and Glassfish 从浏览器(localhost)调用使用Netbeans和Glassfish创建的WebService方法 - Call WebService method created with Netbeans and Glassfish from browser(localhost) 无法使用NetBeans IDE 8.1,Glassfish 4.1运行简单的“ Hello World!”项目 - Unable to run a simple “Hello World!” project using NetBeans IDE 8.1, Glassfish 4.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM