as a database.
There is two scenario I hope you would help me to make the right decision.
There is 10 service (a simple class or function inside app) that each X seconds is calling mysql procedure and sends result with API or websocket.
having a separated connection for each service is better or one mysql connection for all of them?
any idea? 🙄
How would you have one connection for all of them? That doesn't make sense
before starting all services I create a connection and pass in service constructor like below: class App { async init() { const connection = await this.connect() let services = [] for(service in services) { const instance = new service(connection) } } connect(): Promise<connection> { // returns connection } }
when you said service I think most people thought about systemd related stuff not just a class with functions.
Sorry, simply I mean a function or class.
Ahhh, so they aren't actually "services" on their own servers
Yes yes exactly, really sorry for using "service" :D
then I also think having 1 single connection is better. especially since you don't need to commit as often with a single connection
Thank you, got it.
Обсуждают сегодня