简体   繁体   中英

How to Perform loadtest on Node.js Application

Please, I need an expert advice on how to efficiently test a finished Node.js Application. What I want to do is

1. I want to run the test to stimulate for example 100 users are all inserting data into a mongoDB

2. 100 users retriving records from the db

3. 100 users are maybe deleting from the database, I want to check how the system will perform in situations like that. I read about loadtest in npm and it seems to me as a good candidate, but I don't know if I can use this to pass data(post/get) request into the database to actually, see how the system will respond to situation like 100 users all posting real data into the database. I suppose ,loadtest helps with checking the response time of eg 20sec with maybe 40 concurrent request, which is my basic undertanding of the module, I don't know if it has other functionlities like what I am expecting to do. Any advice or clue to go about this will be appreciated,because I wish to avoid re-engineering the wheel if possible Thank you

You can use loadtest module. But first you should define routes for crud processes and call

loadtest -c 10 --rps 100 http://example.com/api/collection

--rps meaning as request per second

You can get it from: https://github.com/alexfernandez/loadtest

You can use Apache JMeter to conduct load test against:

There's no reason you absolutely need to use a node.js utility to conduct load tests on node.js apps. In fact, I would suggest you use a language that supports multiple threads. With node, I'd worry about blocking the event loop, waiting on I/O and getting inaccurate results.

I recently tried vegeta and am very happy with it. You can use it as is without having to write any Golang code (although it's open source and you can modify it as you please). It supports URLs with headers and POSTs with payloads. It is written in Golang, which does support multithreading, and it even reports its latency. You can get reports in html, json and plain text right out of the box

Finally, vegeta scales well. It seems you'd like to issue POSTs, GETs and DELETEs. You can spin up an instance to do your GET loads, another one for POSTs and one for DELETES. Or you can POST a bunch of data, then DELETE the data on the same VM. When all of the VMs are done running the tests, you can look at the results separately or aggregate them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM