Hacker News new | ask | show | jobs
by skohan 1887 days ago
> I use ARC pointers for long-lived shared object (Database connections pool, mailer...)

Does that mean you basically enforce sequential database reads? Seems like a bottleneck if your server is concurrent

1 comments

Arc just allows sharing between multiple threads, it doesn't prescribe any sort of locking.

If they're sharing a connection pool then each HTTP request would get its own connection out of the pool, and they'd be concurrent (access to the pool may or may not be serialised depending on the pool's details, sqlx is internally mutated not externally locked for instance).

The mailer might be behind a mutex (its access completely serialised), or the "mailer" might just be the input side of a queue / channel, and the actual mailing work be done in a separate process (that seems way more likely than bounding the request on sending emails really).