PHP communicating with JAVA server

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
TheProgrammer
Forum Newbie
Posts: 22
Joined: Mon Nov 27, 2006 12:25 am

PHP communicating with JAVA server

Post by TheProgrammer »

Hey everybody,
I have a more tricky situation here and maybe you can throw some ideas.

So, i have a site written in php that needs to communicate preaty intensive with a live server (on the same machine, written in Java), in order to get/set some resources, benefit from some real caching and persistence etc. I have several options for this, and I'm not sure what is best as performance.

1. Classic communication via sockets. This might be slow if i have a socket connect on every page. Maybe with a good setup i can benefit a performance boost from permanent connections.

2. RPC via SOAP or something else. I think this would be slower than sockets.

3. Shared memory communication (pipes?). At a first glance this looks to be the fastest alternative. I'm preaty new to shared memory communication in php, actually in general. I don't know what the connect overhead is but since it's not passing thought the whole tcp/ip protocol stack it should be way faster. The problems might be that the communication is not asynchronous or buffered which could cause big problems, and that the 2 communicator will have to stay on the same virtual machine. Plus, I'm not sure how i can send/receive more complex types of data, like arrays/maps. Maybe there are libraries to handle pipe communication more efficiently. Do you know any?

4. the php-java bridge http://php-java-bridge.sourceforge.net/ looks very nice and interesting and they say that the communication is 50 times faster than with rpc. however, i don't see how i can use it. it only allows me to instantiate java classes in php not communicate with an already started application. maybe if i run php inside a java servlet it could work, but i'm not sure it's the right thing to do since the java server should only be a tool not the main process.

What do you think it's the best choice, or do you know any other? I'm especially interested by performance, but i can't ignore scalability either.
Post Reply