mozilla / fxa-auth-server

DEPRECATED - Migrated to https://github.com/mozilla/fxa
Mozilla Public License 2.0
399 stars 108 forks source link

MySQL read and write operations need different configuration #385

Closed gene1wood closed 10 years ago

gene1wood commented 10 years ago

Currently there is one config for mysql hostname, username, password, etc. which is used to both read and write to the database.

Since we're running on multiple DB servers we will need to different mysql connections, one to the write master, and one to the read load balancer, each with separate config values (hostname, user, pass, etc)

rfk commented 10 years ago

This feeds into a deeper architectural question about how we want to manage the read/write split in the code. IIRC the persona codebase gets around this by basically running two copies of the app, sending read requests to one copy and write requests to another. @chilts may be able to offer some options based on the connection-pool work he's been doing.

chilts commented 10 years ago

It'd be easy enough to set up a read pool and a write pool using the different configs. Presumably we then choose which pool we want to get a connection from for each API call.

e.g. db.createAccount() would be the write pool, but db.accountDevices() could be the read pool.

However, if there are other (read security) reasons to run two separate apps, then yeah, we'd have to think about it a bit more than this. :)

rfk commented 10 years ago

@chilts I was thinking of this thing you showed me: https://github.com/felixge/node-mysql#poolcluster But maybe it's overkill for our situation at this time.

chilts commented 10 years ago

@gene1wood feel free to tell me if you want any ENV VAR names changed to make it betterrer. :sailboat: