views:

98

answers:

4

I'm currently re-developing a fairly large-scale PHP web application. Part of this redevelopment involves moving the bulk of some fairly hefty business logic out of the core of the web app and moving it into a set of SOAP web services.

What's currently concerning me (just slightly) is perceived overhead this brings with it in terms of local HTTP traffic. I should explain that the SOAP web services currently, and for the foreseeable future, will reside on the same physical server, and if and when they move they will remain on the same network. What concerns me is the fact that for each call that was an internal php function call, it is now an http request invoking a similar function call.

Obviously this is something I can measure as we move further along the line, but I was wondering if anyone could offer any advice, or more importantly share any previous experience of taking an application down this route.

+3  A: 

Are you doing hundreds or thousands of these calls a second? If not, then you probably don't have to worry.

But profile it. Set up a prototype of the system working across the network with a large number of SOAP calls, and see if it slows down to unacceptable levels.

Skilldrick
Hundreds, maybe as many as a thousand per second, but definitely not hundreds of thousands. Not yet anyway. If the system were to reach this scale then I doubt refactoring things would be an issue ;)You're right though. There's no real substitute for actually testing the theory out irl.
WibblePoop
Hundreds per second could cause you issues. To me, i would be putting the "core business logic" into a re-usable module. You could then expose that business logic to the "outside world" (third parties) via an API. But for your internal (same computer) comsumption, why not just call the module directly? Like what @symcbean is saying.
RPM1984
That's a valid question. If it wasn't for the fact that this "business logic" was destined for greater things, and with all probability it's own server I would have gone with that option. I can't think of a way for us to develop this as a standalone, fully movable module without it being a web service of some kind. I think we might have to start thinking outside the box in terms of process forking or something to keep the application running smoothly :S
WibblePoop
+1  A: 

Does it HAVE to be a SOAP web service? Is this the client telling you this, or is it your decision?

You seem concerned about HTTP calls, which is fine, but what about the overhead of unnecessarily serializing/de-serializing to/from XML to be transferred over the "wire" - that "wire" being the same machine. =)

It's doesnt really make sense to have a SOAP-based web service where it's only to be consumed by a client on the same machine.

However I agree with @Skilldrick's answer - its not going to be an issue as long as you are intelligent about your HTTP calls.

Cache whenever you can, batch your calls, etc.

RPM1984
The decision to use SOAP is an internal one, but is based on the fact that the functionality exposed by the web services may well be made available to third parties, and SOAP seemed like a safe(ish) cross-platform solution... especially for .Net consumption.XML (de)serialization is obviously also a concern too
WibblePoop
@Jamie, that's valid then. I was about to say "use WCF" because that would be perfect in your scenario (NamedPipes endpoint for app on same machine, wsHttpBinding for other clients), but that's .NET =)
RPM1984
A: 

SOAP is more verbose that REST. REST uses HTTP protocol to do the same with less network bandwith, if that's your concern.

See:

As to really answer your question, remember the 80/20 rule. For that use a benchmarking/tracing tool to help you finding where your hotspots are. Fix those and forget about the rest.

Wernight
IMO - REST is more to do with scalability, meaningful/clean URL's, and resource-based invocation. But i don't think REST vs SOAP is a valid comparison when we are talking about performance of HTTP requests.
RPM1984
+2  A: 

If the server is running on the same physical box then you can't have any privilege seperation. And increasing capacity by adding tiers to the stack (instead of euivalent nodes) is a recipe for non-availability.

If you're hiding something behind SOAP, the the HTTP overhead is likely to be relatively small in comparison to what the 'something' is doing (e.g. reading from database). However when you add up the cost of constructing the SOAP request, decomposing the soap request the compositing the response, add the overhead for HTTP then one has to wonder why you don't provide a shortcut by calling the PHP code implemented within the server directly in the same thread of execution.

If you were to design an abstract soap interface which mapped directly to and from php types then this could be shortcutted without having any overhead in maintining different APIs.

symcbean