Comments (1)
Hi @FeepingCreature, thanks for the issue.
I suspect there's a timing issue where the client tries to start up a batch connection for every event.
Yep, that's exactly what is happening, the cache of batch streams is only populating after the connection was made (which is async) so as you were initiating multiple requests in the same event loop, it was initiating the creation each time.
I've changed caching logic to cache a promise of a batch append stream, so it only gets created once.
This uncovered another issue that the backpressure logic was assuming that only one call was using the stream at a time, so was flooding the connection after the first flush. I've also fixed that.
You can find the PR here: #305
PerformanceTestNodeJsGrpc
If you want to eek out some more performance, using batching will give you the best performance:
For 100,000 events (after #305):
Code in issue
const {
EventStoreDBClient,
jsonEvent,
} = require("@eventstore/db-client");
const client = EventStoreDBClient.connectionString('esdb://localhost:2113?tls=false')
const streamName = "PerformanceTestNodeJsGrpc";
const numberOfEvents = 100_000;
function oneKiloByteEvent() {
return jsonEvent({
type: "AnyEventType",
data: {
value: 'A'.repeat(904)
},
});
}
(async () => {
try {
var requests = [];
for (var i = 0; i < numberOfEvents; i++) {
requests.push(client.appendToStream(streamName, [oneKiloByteEvent()]));
}
await Promise.all(requests);
console.log('Done.');
} catch (e) {
console.log(`append failed: ${e}`);
}
})();
Takes about 38s
Batches of 200, awaiting each call
const { EventStoreDBClient, jsonEvent } = require("@eventstore/db-client");
const client = EventStoreDBClient.connectionString(
"esdb://localhost:2113?tls=false"
);
const streamName = "PerformanceTestNodeJsGrpc";
const numberOfEvents = 100_000;
const batchSize = 200;
function oneKiloByteEvent() {
return jsonEvent({
type: `event`,
data: {
value: "A".repeat(904),
},
});
}
(async () => {
try {
for (let i = 0; i < numberOfEvents / batchSize; i++) {
await client.appendToStream(
streamName,
Array.from({ length: batchSize }, oneKiloByteEvent),
{
deadline: 10_000_000,
}
);
}
console.log('Done.');
} catch (e) {
console.log(`append failed: ${e}`, e);
}
await client.dispose();
})();
Takes about 8s
from eventstore-client-nodejs.
Related Issues (20)
- Ensure rediscovery is not run when the server returns a timeout
- add StreamIdentifier util
- Is there a way how to force release all resources created by client? HOT 5
- Automatically close batch append connection
- Memory leak
- Memory leak HOT 4
- Wrong comment in readStream.d.ts HOT 1
- Memory Leak on readStream HOT 9
- Retrieving batch of events from catchup subscriptions HOT 3
- Feature Request: gRPC-web adapter. HOT 1
- Unable to Connect to Insecure Docker Compose HOT 5
- `emitEnabled` only available on projection update, not on create HOT 2
- Add debug log if `serverFeatures` failed
- ServerFeatures should only assume unknown server on `UNIMPLEMENTED` error
- readUint64String is not a function HOT 4
- created is not a javascript safe integer HOT 2
- Gracefull shutdown HOT 1
- Trouble connecting to cloud cluster from AWS HOT 2
- Please ship a sourcemap HOT 2
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 eventstore-client-nodejs.