I thought I would share my slides from PHP Conference Australia 2016. I spoke about managing state, scaling by adding clones, functional partitioning, data partitioning AKA sharding, challenges that you may encounter and finally I went through a sample application architecture explaining how different scalability techniques can be applied for maximum flexibility and efficiency.
Lets make something clear from the very start: JUST BECAUSE THERE IS https:// IN THE URL OF THE REMOTE SERVICE IT DOES NOT MEAN THE CONNECTION IS SECURE!
I am sorry for the tone of this post but i am enraged by how popular this issue is online. If you ask why i suggest a little experiment.
Steps to follow
- Change your host file settings to point something like www.somedomain.com to your development server
- Create a self signed certificate for this domain and setup a https virtual host to serve it on local IP or alias
- Put a test file on that URL
Just a very short tip as it was a big surprise to me :) If you have xdebug enabled SoapClient will not throw an exception but cause a fatal error.
All you have to do is disable xdebug or make sure that soap service is available.
I have worked with SOAP services from time to time but now i have actually even nicer way to debug them. I still use SOAPUI as its an amazing tool but now i can easily see what is PHP doing :- )
Before, i would simply log everything in raw xml with headers etc. before i sent it out and whenever i got a response back i would log hat too. This is a great way to keep history of what was actually sent and what did we actually get back in case of any investigations etc. It does not impact the performance that much if your volumes of calls are low so you can even enable it temporarily on production servers to see what is there.
Circuit breaker is a component that supports high relaiability of web sites. It helps discovering, at runtime, which of the external dependencies are failing. Having that knowledge application can avaid wasting time on trying to call them untill they are back online.
Current PHP application may depend on several databases, soap/rest web services, external cache providers or data grids, mail, ftp etc.
It is important for the application to keep on functioning even if some of these dependencies fail. To do that application has to be able to track when services become unavailable and when they become active again.
If a database or web service is down we want our application to detect it as soon as possible and react accordingly. Maybe application has a secondary slave database that can be read from? Maybe there is a way to load cached data? If all fails maybe its best just to hide some function or display message that service will be fully functional soon. What we want to avoid is making every user wait 30s for the database connection (which has to fail any way).
UPDATE: project was moved to github a while back as an independant PHP library php circuit breaker
Seems like i am out of luck lately when it comes to books. I must say this book was not really my type. Sometimes it is not easy so describe why, but book is just tough to read.
The thing i did not like about the book was that examples drag for entire pages. I know its difficult to show some things in concise way but i think this book had the longest code examples i have ever seen : -)
Some times you might come across the mysterious web service error in PHP saying: 'Error Fetching http headers'
What it means is that connection or the call itself to the web service took longer than expected. Extensions does not want to wait forever so decides to quit with error.
About the author
Hi, my name is Artur Ejsmont,
welcome to my blog. I am a passionate software engineer living in Sydney and working for Yahoo!
If you are into technology, you can order my book Web Scalability for Startup Engineers on Amazon. I would love to hear what are your thoughts so please feel free to drop me a line or leave a comment.