Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communication between PHP web app server layers on Amazon Web Services

I'm looking into developing a web application hosted on Amazon Web Services and I have a question regarding it's architecture.

Looking at the diagram below from Amazon, they've got 3 layers; a web server serving users via HTTP, an application server processing business logic, and a database server. This is perfect for our use and the separation of web and application logic is great, however I have a question regarding the communication between the layers.

The app's code is going to be written in PHP. The communication between the application server and the database server can be done by PHP's mysqli extension (to the host db server via port 3306 by default). This is fine, however I'm unsure how communication would be made between the web server and the application server during a user's HTTP request, and what the best way of doing it is.

I've read up about XML/RPC, or possibly JSON/RPC, but is this the right thing that I'm looking for? Or is communication between different PHP server layers usually done another way?

Any advice would be greatly appreciated.

Recommended AWS Web App Architecture

like image 777
Steve Avatar asked Apr 10 '11 12:04

Steve


2 Answers

There's a big chance the interfaces you have to develop for your application layer will be different for several apps. One way to have a generic approach for this is building more abstraction.

It can be implemented in a lot of ways, in PHP or maybe some other technology in between. You could read up about Webservices (WSDL, SOAP, WSO2.org PHP-specific), REST, RPC-style (you mentoined it), RMI (Java), Corba, JAXB, several project from the Apache Foundation, Google's protocol buffers, or implement your own protocol; Staging databases could also be a helping hand in some cases.

I think your question is too general to really "answer" it. It's one of the first questions you'd have to answer when setting up an architecture like this.

like image 68
Robert de W Avatar answered Oct 28 '22 06:10

Robert de W


If you are using PHP as the backed then you are most likely going to have your webservers and "application" servers on the same machine (Apache + php) so the diagram from amazon doesn't really apply in this case. One thing that you may want to look into is putting a machine in front of your webservers (nginx or the like) to reverse proxy the requests back to your webservers, or maybe look into ELB from amazon.

like image 30
Matt Avatar answered Oct 28 '22 07:10

Matt