Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Query] acraserver in distributed environment behind load balancer #696

Open
3 tasks done
devendermishra opened this issue Jan 4, 2024 · 4 comments
Open
3 tasks done
Assignees
Labels

Comments

@devendermishra
Copy link

devendermishra commented Jan 4, 2024

Describe the bug
I want to know if acra can be run in multiple servers/pods behind a load balancer to ensure better availability.

To Reproduce
NA

Expected behavior
NA

Acra configuration files
NA

Environment (please complete the following information):

  • Acra version: [0.95.0]

  • Database server and its version: [MySQL 5.7, MySQL 8]

  • Installed components:

    • AcraServer
  • Data-in-transit encryption between Acra and the client-side application:

    • no transport encryption
  • Installation way:

    • via Docker

Additional context
In distributed environment, a node may go out of service unexpectedly. In order to ensure that acraserver works in such case to use multiple server behind load balancer. So, I want to know that if acraserver can work in such settings. Also, want to know what are recommendations to ensure better availability.

@vixentael
Copy link
Collaborator

Hi @devendermishra!

Yes, Acra server works well with horizontal scaling.

Acra has the whole sections in the docs regarding optimisation, which includes vertical and horizontal scaling:
https://docs.cossacklabs.com/acra/configuring-maintaining/optimizations/

Acra also has the Balancer demo with AcraServer, PostgreSQL and HAProxy which demostrates different combination: balancer before the databases, or balancer before AcraServers
https://github.com/cossacklabs/acra-balancer-demo

Hope it helps!

@devendermishra
Copy link
Author

Thanks @vixentael for prompt response. My question is related to MySQL 8 based clients. Currently, MySQL 8 client is not supported. However, acra needs to store the capability of connected client. How that will work in case of horizontal scaling?

@devendermishra
Copy link
Author

In the given demo, there is 1 acra server per DB. I want to know if we can have multiple acra server per DB (especially MySQL).

@Lagovas
Copy link
Collaborator

Lagovas commented Jan 11, 2024

My question is related to MySQL 8 based clients. Currently, MySQL 8 client is not supported.

However, acra needs to store the capability of connected client.

For now, Acra doesn't store it. Your balancers should park the same client's connection to the same AcraServer and AcraServer will use the same database. Database wire protocols are stateful and operate with client sessions. Every session has its own set of registered prepared statements, opened transactions, connection parameters, db variables, and so on. So, the same client's connection should be proxied to the same database that handle that connection. You can scale your infrastructure by X database instances and every instance should have own AcraServer instance.

In the given demo, there is 1 acra server per DB. I want to know if we can have multiple acra server per DB (especially MySQL).

Yes, you can. But it depends on how your apps will connect to the AcraServer/Database. Let's use next example. You have a service parallelized into 2 instances and it uses a pool of connections of size 2. How you will distribute connection between different AcraServers?

  • You can configure every instance to use different instances of AcraServer. First intance uses AcraServerA, the second uses AcraServerB. Or every odd app instance uses AcraServerA and other uses AcraServerB.
  • You can configure your apps to connect to the AcraServer by it's domain name and DNS record will have X IP addresses of AcraServer instances. If your db drivers in app support round-robin strategy - then it will be scaled. If they will use only the first IP - it will not be scaled. Depends on db driver on app side or you need to write your own logic. In such case, the same instance can have 2 connections routed to 2 different AcraServer instances.
  • You can use any TCP proxy (for example haproxy) that will route connections from the app to different AcraServers using round-robin or any other strategy - it will work. One connection will use own AcraServer instance until close. AcraServer will store the connection state until it closes. In this case, 2 different instances can have 2 connections routed by proxy to 2 different AcraServer instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants