Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good practice to deploy webservices? [closed]

Is it a good practice to deploy web services separately or should they be part of the web application? For instance, I am developing a spring rest based web service. The function of this service is to, let's say, to get user data.

Each webapplication that queries this web service has it's user data in different schema. So, now the webservice will need to know who is calling it - is it Appilcation A or Application B? If it's AppA, then it should get data from Schema A, if it's AppB, then its another schema. Note, that AppA and AppB are just the same code packed into two different wars and the schema they are supposed to query is supplied from properties file.

In a situation like this, does it make sense to pack the webservice with the webapp code and deploy it under different contexts, so it becomes a duplciate service running in a different context. Or, should it be deployed separately and somehow the AppA and AppB are supposed to identify themselves to this web service?

like image 640
Jay Avatar asked Aug 24 '15 14:08

Jay


1 Answers

I prefer below approach, which is in use for 50K concurrent users.

  1. Make sure that each web service encapsulates both UI and Schema independently by executing required business use case. Each web service will have all three layers - Model, View and Controller for that business service. That means your App-A is one web service & App-B is other web service.
  2. All web services will register and un-register with Master web service. Master web service is responsible to redirecting user request to appropriate web service like App-A OR App-B.
  3. You should have cluster of Master web service & cluster of individual web services - App-A & App-B

  4. In this approach, your schema can reside on different database instead of single database

Advantages of this approach:

  1. Each web service can scale horizontally. Just add additional VM nodes if you want to increase the scale.

  2. If you have different schemas on different databases in different locations, you are avoiding network performane bottlenecks in OLTP queries (Online transaction processing queries).

Disadvantages:

  1. I see only one disadvantage since Master Web Service acts like a Facade and it should know the internals of individual web service. But it's not a drawback for the advantages it is offering if you consider the trade-off.
like image 116
Ravindra babu Avatar answered Sep 18 '22 20:09

Ravindra babu