Multiple web services design questions

Hi,

Actual setup
We are using 3 web service apps to support our platform functionalities. They are running on a Windows Server as standalone services. A server is dedicated to the database and services and web apps are hosted on a distinct server. The web services are :

  • report generator
  • data exporter
  • API that receives requests from the mobile app

The API receives POST request from the mobile device. It actually handles the following 4 tasks. They are all handled individually with a specific URL for each of them :

  1. User authentication - (short JSON string in and out)
  2. Query the database and send data TO the mobile device - (short JSON string in and long JSON string out)
  3. Receives Type 1 data FROM mobile device - (long JSON string in and short JSON string out)
  4. Receives Type 4 data FROM mobile device - (long JSON string in and short JSON string out)

We will be adding a 5th task
5. Receives picture files (normally 6 to 25 picture files) just after receiving 3 or 4.

Note: We used to send the pictures along with the data but, due to stability issues on the mobile app side, we now send the pictures separately.

Questions
1- We are using the most powerful server for the database and services. Is that the best choice?
2- We are planning to add the service responsible for saving the pictures the web app server (saving the pictures on that same server) to have faster picture loading. is that a good choice?
3- Should services coexist with web apps instead?
4- Would that be better to split the actual API into 4 individual services with their own port and standalone entity?

Thanks in advance!

Roger

I think so. Databases are pretty resource-hungry.

Instead of putting it on the web app sever? In general I think it makes sense to keep your web services separate from the web app.

It depends on usage, I suppose. Xojo web apps only utilize a single CPU core. If there will be a lot of hits to the web app and web service API calls, then splitting them makes sense and is probably a better overall design.

So I would probably split the web app and the web service stuff to 2 apps to start with.

If you’re expecting a lot of calls to the web services, and they are truly separate functionality, then also breaking them up into separate apps would allow each of them to have their own CPU core, which would improve performance. If a lot of the functionality is shared then keeping them as a single app and putting a load balancer in front to start more instances as needed might be a better option than having multiple projects to maintain.

Thanks Paul,

If you don’t mind, I’d ask a couple more questions. I re-read my post and noted that it wasn’t clear on some aspects. Here some clarifications :

Server “weak”

  • The main web app (platform interface) runs as a standalone service
  • Pictures sent by the mobile app are currently stored here

Server “strong”

  • PostgreSQL database
  • 3 web apps (standalone services) acting as a report generator, data exporter, and communication API to link the mobile app to the database and server. The API deals with all POST requests coming from the mobile app : authentication, sending and receiving data (including pictures). The pictures (Base64 encoded) are received as part of the unique JSON string sent by the mobile app.

We are planing to send the pictures separately from the other data and to use a separate API (web app) to deal with the POST requests containing the pictures.

From your answers I understand that :

  • Better putting the database on server “Strong”
  • Keep the services apart from the main app. So put them on server “Strong” along with the database
  • Having individual web apps for each functionality would allow us to use more efficiently the processing power of the server or using a load balancer to have more instances running at the same time.

Complementary questions :
The pictures are saved in 2 copies : one at full resolution and the second at lower resolution. The web app uses the smaller version of the picture to display them. The report generator uses the full resolution version of the pictures to create reports.

  • Which of the following situations seems better?
    a) server “weak” with main web app, low-res pictures and picture-API (high-res pictures on server strong)
    a) server “weak” with main web app and low-res pictures (picture-API and hi-res picture on server “Strong”)
    c) server “weak”, main web app only (all pictures and picture-API on server “Strong”)

Since we don’t plan to add a third server for the moment :

  • Is it possible to use a load balancer on a single server?
  • If so, would that increase the computing power even if instances are created on the same server?

Thank you for your support!

[quote=418899:@Roger St-Arneault]- Which of the following situations seems better?
a) server “weak” with main web app, low-res pictures and picture-API (high-res pictures on server strong)
a) server “weak” with main web app and low-res pictures (picture-API and hi-res picture on server “Strong”)
c) server “weak”, main web app only (all pictures and picture-API on server “Strong”)[/quote]
I’d go with “c” and maybe implement some caching of the low-res pictures within the web app itself to minimize API requests.

[quote=418899:@Roger St-Arneault]Is it possible to use a load balancer on a single server?
If so, would that increase the computing power even if instances are created on the same server?[/quote]
I’m not really an expert on load balancing. There was a session at XDC 2016 on load balancing with HAProxy by John Joyce. He also has a blog post about it. Essentially, the load balancer runs on the server and all traffic goes through it. The load balancer decides what to do with the incoming traffic. So it could pass DB requests along to the DB and intercept request to Xojo stand-alone web apps to pass them along to running instances or start new instances as needed. HAProxy is very flexible, but you’ll have to spend time learning how it’s all configured. A load balancer doesn’t increase computing power of the server but in the case of Xojo apps allows them to make better use of the computing power that is available.

That’s what I meant :wink:

And thank you very much. I’ll take a look at the blog.