Can one client connection be used for the lifetime of an app?
See original GitHub issueSince as of version 3.0.0 per https://github.com/jbielick/faktory_worker_node/blob/master/CHANGELOG.md#300--2019-02-11, a connection pool is added to each client, is it advantageous/recommended to instantiate a single client connection to be used for the lifetime of an app?
Also, can you clarify what is meant by (taken from the changelog):
Client.connect() not necessary before using connection Client.connect() now connects and disconnects to test the connection details. A connection is created in the pool when it is needed.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Redis one connection per application lifetime - java
This connection would be used by various functions. Or the alternative is better: scoping each connection to the method, which would then ...
Read more >Understanding and Handling Connection Lifetime Events ...
This article provides an overview of the SignalR connection, reconnection, and disconnection events that you can handle, and timeout and ...
Read more >MySQL Connection Handling and Scaling
A long lived connection is a connection that is open “indefinitely”. For example one might have a Web server or an Application server...
Read more >You're using HttpClient wrong and it is destabilizing your ...
> HttpClient is intended to be instantiated once and re-used throughout the life of an application. Especially in server applications, creating ...
Read more >What's the connection lifetime in the pool? / When are idle ...
I noticed that the original driver has the Connection Lifetime option, the doc says: When a connection is returned to the pool, its...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Absolutely! And as for closing: I would try and do so, but it’s not typically critical.
SIGINT or whatever signal you’re sending typically terminates those connections, but it can be helpful to
await client.close()to shut down the connection pool gracefully. I wouldn’t worry too much about it unless you’re having issues.Also—you may have omitted some small details for brevity, so forgive me if these are already known.
faktory.connect()is async, so you’ll want toawaitthat before starting your server. This ensures the connection is possible and ready before starting your app (helpful when it comes to health checks). I’d recommend adding the client to the request object in a middleware so it’s available to all HTTP handlers instead of relying on the closure having access to theclientvar. It would look something like this:But again, if you don’t have any issues you’re probably fine. Feel free to disregard.
Excellent! Yep, was going to use express middleware just like your code snippet. Thanks again!