Java Glassfish-打开太多文件

时间:2018-07-31 13:21:40

标签: java mongodb glassfish socketexception

我有一个在Glassfish服务器上运行的后端部署,我的应用程序的前端在需要一些数据时会发送REST请求。另外,后端连接到Mongo数据库:

前端<---- rest ----> BACKEND <----> DB。

我的后端通过glassfish 5部署在Ubuntu虚拟机上,前端在Apache Web服务器上运行。

使用一段时间后,我们可以说5分钟后,尤其是当多个用户正在使用该应用程序时,glassfish服务器在尝试访问数据库时大部分时间都崩溃,错误为:java.net.SocketException: Too many open files

当然,我已经在Google上搜索了此问题,并且有许多建议只是说要增加打开文件的数量,而现在1024

现在我的问题是,这些打开的文件是什么,即使我增加了它们,过一段时间也不会达到限制。是增加唯一的解决方案,还是我的编码中可能有错误?预先感谢。

编辑: 这是我的ubuntu机器的netstat输出的一个片段:

tcp        0      0 localhost:27017         localhost:44856         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44980         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44794         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45132         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44764         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44814         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44756         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44374         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44926         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45040         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45276         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44858         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45052         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45310         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44806         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44840         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45046         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45222         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45160         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44990         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44914         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:45274         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44998         ESTABLISHED -               
tcp        0      0 localhost:27017         localhost:44788         ESTABLISHED -               
tcp6       0      0 localhost:45176         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:45136         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:45058         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44926         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44968         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:45190         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:45050         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44886         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:45308         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44978         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:45086         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:45198         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44922         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44938         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:45020         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44896         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44830         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44960         localhost:27017         ESTABLISHED 5204/java       
tcp6       0      0 localhost:44776         localhost:27017         ESTABLISHED 5204/java

如您所见,有一种方法可以与mongo数据库localhost:27017建立连接。

0 个答案:

没有答案