How can I communicate between PHP and a Java program? -


I am working on a web application that often needs a calculated intensive query to run, resulting in these Uses 500ms about this query, using a different table MySQL (as optimized as possible, believe me). To eliminate this barrier, I have created a Java program that loads relevant DB data into memory and queries itself; It takes about 8ms (which I'm proud of) I want to use this Java program to get results, and if it is unsuccessful or unavailable, the failure to run mysql query in PHP

The data in the Java application takes some time to load, it is going to be loaded once and running as a background process. Now, the question is how do I communicate with PHP via this Java application?

Keep in mind:

  • Many examples of PHP may need to be communicated simultaneously with this Java process.
  • If the Java instance (such as: crash for some reason) can not be found, PHP can progress by using the old and slower MySQL method.
  • An intermediary process, such as memcatch, is acceptable.
  • Ideally, the solution will face the race conditions.
  • I would not like to use MySQL primarily as intermediate.

I was going to use a memcatch, where PHP writes a known key and pope until the key is changed to "complete", unless it chooses the key And once found that someone works and sets it "to complete" However, it will not work for two reasons First of all, read / write on MacC using both PHP and Java serialized objects. , And there is no way to change it Land, and I do not want that Java must Ansulit the PHP object and vice / Varnas - it is very messy. Second, this is not an ACID compliance - if there is a queue then the race conditions will be there.

For now, I'm stuck with the voting MySQL "Selection" to see if a queue is closed or not, which is far from the optimal solution because there will be a need to be slow during voting , So mysql does not ping too many times i need a better solution!

Thank you.

Edit: Duh It seems that I am using some sort of socket server in Java, which I am unfamiliar with may be an example :)

< P> I am using socket server on java end, and PHP sockets work great on php end.

There is no need to do things more with PHP / Java Bridge, and no need for overhead to create a web server.

Sockets work great, and I'm really bit embarrassed I even asked questions for starting work.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -