I'm using Apache PHP for my web application. I'd like to use the exec
function in PHP and call a java class (Im not going to be using a java to php bridge), however this now requires not only distributing the request thread in apache but also starting a new JVM with the java execution. Is this going to be extremely large of a load on server resources if we have a significant amount of users?
The only reason I'm not doing a java to php bridge is because it seems a bit difficult and time consuming to get up and running.
You need only one java process to make this work. Write a Java Socket server. Then you can write a PHP Client with PHP Sockets to send commands to your Java Server which do the work.
Yes, starting a new process (Java or otherwise) for each request is going to perform very poorly.
Google App Server does this and it can handle in the order of 2 to 10 requests per second per server. If you use a Java server which is running all the time you should expect around 100-1000 requests per second. If you use a persisted connection, and efficient messages, you can handle over 100K message per second.
In short, it could work but I would have trouble accepting such a inefficient solution. ;)
来源:https://stackoverflow.com/questions/17507375/is-instantiating-a-new-jvm-for-every-server-request-a-large-load