Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to 'web enable' a legacy C++ application

Tags:

c++

rest

c

apache

wt

I am working on a system that splits users by organization. Each user belongs to an organization. Each organization stores its data in its own database which resides on a database server machine. A db server may manage databases for 1 or more organizations.

The existing (legacy) system assumes there is only one organization, however I want to 'scale' the application by running an 'instance' of it (tied to one organization), and run several instances on the server machine (i.e. run multiple instances of the 'single organization' application - one instance for each organization).

I will provide a RESTful API for each instance that is running on the server, so that a thin client can be used to access the services provided by the instance running on the server machine.

Here is a simple schematic that demonstrates the relationships:

Server 1 -> N database (each organization has one database)

organization 1 -> N users

My question relates to how to 'direct' RESTful requests from a client, to the appropriate instance that is handling requests from users for that organization.

More specifically, when I receive a RESTful request, it will be from a user (who belongs to an organization), how (or indeed, what is the best way) to 'route' the request to the appropriate application instance running on the server?

like image 806
morpheous Avatar asked Nov 05 '22 10:11

morpheous


1 Answers

From what I can gather, this is essentially a sharding problem. Regardless of how you split the instances at a hardware level (using VMs, multiple servers, all on one powerful server, etc), you need a central registry and brokering layer in your overall architecture that maps given users to the correct destination instance per request.

There are many ways to implement this of course, so just choose one that you know and is fast, and will scale, as all requests will come through it. I would suggest a lightweight stateless web application backed by a simple read only database that does the appropriate client identifier -> instance mapping, which you would load into memory/cache. To add flexibility on hardware and instance location, use (assuming Java) JNDI to store the hardware/port/etc information for each instance, and in your identifier mapping map the client identifier to the appropriate JNDI lookup key.

like image 65
Peter Avatar answered Nov 12 '22 16:11

Peter