user2061482
user2061482

Reputation: 21

Is PHP Java Bridge having same performance as JSP->Java?

I am building a website which will have a rigorous database access. It should also have a good exception handling mechanism and be fast. To avoid DB access, I want to load some of the values in RAM using Java.

  1. Inorder to handle MySQL DB handles issue, I am creating a pool of DB handles and accessing them using threads in Java.
  2. The Java shall provide interfaces to access the values present in RAM as well as provide user management and some other interfaces.
  3. I need detailed error handling and exception handling is great in Java as compared to PHP.

Now my problem is:

  1. Accessing Java objects in PHP is an issue because it does not have a great system to store values in PHP.
  2. Also, PHP access to Java is required through PHP bridge.

So, Should I use JSP? But JSP is not available on all servers, so thats a dilemma for me.

Is PHP -> Java bridge a good solution? Is it scalable and has good performance as compared to JSP->Java combination

Upvotes: 2

Views: 546

Answers (1)

Colin M
Colin M

Reputation: 13348

This is actually a common situation. While not necessarily in Java, it is common practice to have compiled back-ends to a pseudo-interpreted (I know PHP isn't an interpreted language) front end. Then, you get the benefits of speed and thread-persistence in a language such as Java with the iterative capabilities (read: no compilation necessary) of a PHP front end.

My advice would be for you to check out the Apache Thrift project. This will generate common interfaces between a Java server and PHP client which allow you to execute service calls from your PHP environment and pass them off to Java.

Basically, in PHP, you establish a TCP connection to your Java server. Java does the database call, loads the data, whatever else it needs to do, and returns the object back to you in PHP. Thrift will help you create consistent objects and interfaces and keep them in sync between the two environments.

Upvotes: 1

Related Questions