KoteiIto / node-athena

a nodejs simple aws athena client
MIT License
105 stars 73 forks source link

Singleton createClient function #26

Closed SengitU closed 6 years ago

SengitU commented 6 years ago

Hello,

First I would like to ask a question, does the createClient function returns a new AWS connection every time we call it?

Do you think having a singleton createClient function would be nice? If so, should I create a pull request with a method called createClientSingleton for this purpose?

Thanks, Ugurcan

KoteiIto commented 6 years ago

Thank you for your question.

Since this library uses api of aws-sdk, createClient does not create a connection. It is created when execute is executed. You can restrict the connection by limiting the maxSockets of the https module.

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-configuring-maxsockets.html

Executing this in the library will affect the entire application, so if you want to limit it, you'd better set it up on the caller side.

However, since concurrentExecMax is restricted for each client object, if you create multiple clients and execute multiple queries asynchronously, it may exceed the above values, so I'd like to fix it.