thenativeweb / node-cqrs-domain

Node-cqrs-domain is a node.js module based on nodeEventStore that. It can be very useful as domain component if you work with (d)ddd, cqrs, eventdenormalizer, host, etc.
http://cqrs.js.org/pages/domain.html
MIT License
269 stars 57 forks source link

How to use in AWS Lambda #138

Closed bikerp closed 5 years ago

bikerp commented 5 years ago

Hi, I'd like to use your project in AWS environment using Lambda. I have already tried but it seems that initialization takes too long (approx. 2 seconds). Any idea what part of the code could be ommited in AWS? Thanks Pavel

adrai commented 5 years ago

probably the parsing of the files takes too much time.... try to run it with DEBUG=domain* to see what takes so much time... btw: this module was never built to use for an "on-request" execution...

bikerp commented 5 years ago

Thanks for the response. It seems that the eventstore initialization takes most of the time. Could you please explain meaning of individual fields of events table (DynamoDB) in eventstore? I have some idea but I'd like to be sure. Thanks

adrai commented 5 years ago

Perhaps @developmentalmadness can help?

developmentalmadness commented 5 years ago

Haven't looked at this for 2.5 years now so I don't remember the mechanics. But we used this in Lambda exclusively on the project I was working on at the time. I haven't followed progress, so I don't know if anything has changed to affect it's ability to run in that environment since.

As for the slow initialization time you may want to look at the ReadCapacityUnits and WriteCapacityUnits. In the module the defaults are not set to production values for cost reasons. Having them set so low also achieves two other goals: forcing you to think about what they should be before going to prod instead of getting caught by the defaults; and running the tests verifies that the retry logic around throttling is working. You'll need to configure those in your startup to reflect the capacity requirements for your project.

One other reason could be the first time you initialize the module it will create the table in DynamoDB for you. When it does it waits until the table becomes active. This process likely takes some time as well.

bikerp commented 5 years ago

Thanks for the answers