Hi fellow lemmings,

currently, I am working on a small project, where I am in need of some help. My project consists of multiple services, that depend on each other. The stack consists of front-end, middle-tier & back-end/database. To get a detailed answer, I try to formulate my question thoroughly.

Front-end:

On top of the stack are running two services. Both of them need to access the DB via a middle-tier.

Web service & API

One service will offer the web interface & the REST API for automated services. It will be hosted by a python web service. The skeleton for this part is mainly done. The service needs to communicate with the middle tier to manage user actions.

Executor service

A second service of the front-end will manage the executing part of the service and interacts with the internet. It will be written in python as well. The service needs to communicate with the middle tier to get the instructions it’s supposed to execute.

Middle tier

The middle tier will act as a interface between the front-end services & the database. I’d like to implement it in C. The service is supposed to receive input from the front-end services, process it and access the database. Further features are planned but not necessary for the first release.

Back-end/Database

The back-end will be the database system. It should only be accessed by the middle tier (preferably with a connection pool).

As far as I planned the project, I intend to run the front-end and the middle tier services on the same machine.

Question Section

Well, if you read everything until here, you are probably willing to help. I am done with the skeleton for the front-ends, I am done with the table structure for the back-end. Also, the communication from the middle-tier to the database won’t be a problem. But I am struggling a bit with the communication between the front-end services and the middle-tier. What is common practice to communicate between a C service and Python services?

My ideas is to make use of common network approaches. For instance, could I host a REST service on the middle tier as well. This raises some fears, because I think this will be the bottle neck in terms of performance. Can you confirm? Alternatively, I was thinking of other IPC features like Unix Message Queues or system sockets. The latter one seems to be my favorite solution.

Unfortunately, I don’t have too much experience with inter process communication and would like to ask for your advice. How would you solve my problem?

Thank you very much for an answer.

Yours rr

@nutomic
admin
11Y

Is there any particular reason why you want to split up your service into multiple processes like this? Putting it all in the same program would surely make things easier, especially if you are going to run it on the same machine anyway.

And instead of C, why not use Rust? ;)

@randomrhino
creator
21Y

C is easier to get familiar with it. I studied Rust during the summer, but I figured out, that I have to come back to rust later this year. It’s still on my agenda, but not for now.

If I decide against the middle tier service, then I won’t have a single point of access for the database. It will result in having two different services accessing the same database. It’s an architecture I don’t necessarily appreciate. Counter question: What’s the problem with this modular structure consisting of multiple microservices?

@nutomic
admin
11Y

Well you need to create some kind of API to communicate between these services, and then you probably need to document this API and keep it stable. Whats the problem with having multiple database connections? Thats what databases are made for.

@randomrhino
creator
11Y

I will use multiple database connections. But I want to have a single service in the middle. Why is it so hard to understand? Isn’t modularity an achievable characteristic for a service? I will use multiple domains. And each domain will have their own service hosted. Since, all domains need to access the same data, I just like to use a middle tier for it. It makes sense, because I just need one configuration for the middle tier. I don’t want to maintain the same configuration for multiple services.

General Programming Discussion
!programming

    A general programming discussion community.

    Rules:

    1. Be civil.

    Other programming communities:

    • /c/rust
    • /c/python
    • /c/powershell
    • /c/haskell
    • /c/fpcomplete
    • /c/cpp
    • /c/c_programming
    • /c/julia
    • 0 users online
    • 4 users / day
    • 9 users / week
    • 24 users / month
    • 187 users / 6 months
    • 2372 subscribers
    • 626 Posts
    • 811 Comments
    • Modlog