Comments (13)
Any word on this? Do I need to do anything to use a connection pool or is it automatic? How is this still open after 3 years?
from elasticsearch-js.
@spalger I've just come across this as well and after poking through the source, it appears that the connection pool that's implemented is a pool of connections to nodes in the Elasticsearch cluster, one per host, is that correct?
More to the point: it's not a pool of open keep-alive connections for each host to avoid the cost of establishing the HTTP connection to a host to begin with as is typically meant by connection pooling in the context of database connections. Is that true?
If one did want pooling, for instance, using generic-pool
, does this seem appropriate (and does pooling these clients make sense if there may be multiple concurrent code paths that work with Elasticsearch):
import elasticsearch from 'elasticsearch';
import { createPool } from 'generic-pool';
const pool = createPool({ create, destroy }, {
max: 40,
min: 4,
idleTimeoutMillis: 1000,
});
async function create(): Promise<elasticsearch.Client> {
const client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace',
apiVersion: '5.0',
});
// ensure connection has been created
await client.ping({ requestTimeout: 1000 });
return client;
}
function destroy(client: elasticsearch.Client): Promise<void> {
client.close(); // no way to tell when connects are actually closed
return Promise.resolve();
}
from elasticsearch-js.
@wbyoung the connection pool implemented in the client does not actually pool sockets as one might expect (naming was chosen before I implemented the standard Elasticsearch client design). That said the HttpConnection
object, the default connection class used in node.js, creates a unique agentkeepalive agent that has a pool of keepalive sockets for that es host/connection/node
from elasticsearch-js.
Reconnection will happen automatically, after the deadTimeout. There are several other configuration options applicable to the connection pool detailed in the configuration section.
You're right though, I do need to write more about the overall design and what is and isn't handled by the module.
from elasticsearch-js.
@spenceralger It says coming soon under connection pool in the configuration section.
from elasticsearch-js.
+1 This would be very helpful if it is necessary
from elasticsearch-js.
+1, please document the client pool behavior. Relates to #165
from elasticsearch-js.
For the love of god document this 👍
from elasticsearch-js.
Please document this ASAP. We just wasted so much time trying to build our own pool.
from elasticsearch-js.
Hi! I'm closing this due to inactivity, if it is still an issue, please feel free to reopen! :)
from elasticsearch-js.
@wbyoung can you provide a more complete example of using generic-pool ?
from here #16 (comment)
from elasticsearch-js.
@sibelius not better than what's above… it's been 6 years and I'm no longer working on the project that used this. Your best bet would probably be the docs for geberic-pool
.
from elasticsearch-js.
it will create 1 elastic search client per pool ?
from elasticsearch-js.
Related Issues (20)
- Bulk helper: Support streaming use/inifinite streams or generators HOT 1
- Support for OpenTelemetry HOT 1
- ES|QL Cursor API helper
- ES|QL Apache Arrow Support
- [Explore] High Level DSL Client
- Scroll helper ignores and hides failed shards
- synonym_set property in the filter setting doesn't exist in. AnalysisSynonymTokenFilter type
- Docs for putLifecycle has wrong parameters HOT 5
- Support for Node URLs with Subpaths HOT 1
- Configurability of OpenTelemetry instrumentation
- In version 8.xx you removed support for disablePrototypePoisoningProtection which is causing our project to run 50% slower HOT 3
- Missing types for role_descriptors
- Issue in Node -v 16 and eleastic search -v 8.12.2 connectivity HOT 2
- Property 'buckets' does not exist on type 'AggregationsCardinalityAggregate'. HOT 1
- Migrate integration test suite to use elasticsearch-clients-tests
- x-elastic-client-meta is not properly reporting when Undici is being used
- There is no "client.connector" HOT 1
- Update docs to include recommended configuration for timeout/keepalive based on ES recomendations HOT 1
- Support for alternative JavaScript runtimes HOT 2
- [Documentation] Document where the deserialization is not emitted HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-js.