postgresql 为什么在我运行我的应用程序时会创建这么多“postgres.exe”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6849536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why so many "postgres.exe" are created when I run my application?
提问by javauser71
I have a J2EE application, deployed in JBoss6 application server in Windows (Vista 32 bit)platform. My database is "PostgreSQL 9.0.4" and I am using JDBC driver: "postgresql-9.0-801.jdbc4.jar".
我有一个 J2EE 应用程序,部署在Windows(Vista 32 位)平台的JBoss6 应用服务器中。我的数据库是“ PostgreSQL 9.0.4”,我使用的是 JDBC 驱动程序:“postgresql-9.0-801.jdbc4.jar”。
In my ds.xml file, I have defined max-pool-size = 75and min-pool-size = 40. i am using JPA/Hibernate as well as using javax.sql.DataSource.
在我的 ds.xml 文件中,我定义了max-pool-size = 75和 min-pool-size = 40。我正在使用 JPA/Hibernate 以及 javax.sql.DataSource。
In windows "Task Manager", I find that when PostgreSQL server starts up it creates 6 "postgres.exe" processes. Now when I deploy/start my J2EE application in JBoss, I find a total of 66"postgres.exe" processes. So that means another 60 postgres processeswere spawned (or launched) because of my application started.
在 Windows“任务管理器”中,我发现当 PostgreSQL 服务器启动时,它会创建6 个“postgres.exe”进程。现在,当我在 JBoss 中部署/启动我的 J2EE 应用程序时,我发现总共有 66 个“postgres.exe”进程。所以这意味着由于我的应用程序启动,另外60 个 postgres 进程被产生(或启动)。
If I change the max-pool-sizeto be 40then I notice that I have a total of 46 postgres.exe processes. In both cases the no. of postgres processes comes down to 6 when I stop my J2EE application.
如果我将max-pool-size更改为40,那么我会注意到我总共有46 个 postgres.exe 进程。在这两种情况下,没有。当我停止 J2EE 应用程序时,postgres 进程的数量减少到 6 个。
So my question, is this normal? Are those extra processes spawned/launched because of 'connection pooling' (used by Hibernate)?
所以我的问题是,这正常吗?这些额外的进程是否因为“连接池”(由 Hibernate 使用)而产生/启动?
回答by Frank Heikens
Yes, this is normal. From the manual:
是的,这是正常的。从手册:
The PostgreSQL server can handle multiple concurrent connections from clients. To achieve this it starts ("forks") a new process for each connection. From that point on, the client and the new server process communicate without intervention by the original postgres process. Thus, the master server process is always running, waiting for client connections, whereas client and associated server processes come and go.
PostgreSQL 服务器可以处理来自客户端的多个并发连接。为了实现这一点,它为每个连接启动(“分叉”)一个新进程。从那时起,客户端和新的服务器进程在没有原始 postgres 进程干预的情况下进行通信。因此,主服务器进程总是在运行,等待客户端连接,而客户端和相关的服务器进程来来去去。