diff --git a/loadtest/README.md b/loadtest/README.md index fcd0d0b6..7082cd07 100644 --- a/loadtest/README.md +++ b/loadtest/README.md @@ -19,4 +19,47 @@ Run it with (after [installing Gatling](https://gatling.io/docs/current/installa gatling.sh -sf . -rsf . -rd "na" -s tinode.Loadtest ``` +Currently, three tests are available: + +* `tinode.Loadtest`: after connecting to server, retrieves user's subscriptions, and publishes a few messages to them one by one. +* `tinode.MeLoadtest`: attempts to max out `me` topic connections. +* `tinode.SingleTopicLoadtest`: connects to and publishes messages to the specified topic (typically, a group topic). + +The script supports passing params via the `JAVA_OPTS` envvar. + +Parameter name | Description +-------------- | ------------- +`num_sessions` | Total number of sessions to connect to the server +`ramp` | Time period in seconds over which to ramp up the load (`0` to `num_sessions`). +`publish_count` | Number of messages that a user will publish to a topic it subscribes to. +`publish_interval` | Maximum period of time a user will wait between publishing subsequent messages to a topic. +`accounts` | `tinode.Loadtest` and `tinode.SingleTopicLoadtest` only: Path to CSV file containing user accounts to use in loadtest (in format `username,password[,token]` (`token` field is optional). +`topic` | `tinode.SingleTopicLoadtest` only: topic name to send load to. +`username` | `tinode.MeLoadtest` only: user to subscribe to `me` topic. +`password` | `tinode.MeLoadtest` only: user password. + +Examples: +```shell +JAVA_OPTS="-Daccounts=users.csv -Dnum_sessions=100 -Dramp=10" gatling.sh -sf . -rsf . -rd "na" -s tinode.Loadtest +``` +Ramps up load to 100 sessions listed in `users.csv` file over 10 seconds. + +```shell +JAVA_OPTS="-Dusername=user1 -Dpassword=user1123 -Dnum_sessions=10000 -Dramp=600" gatling.sh -sf . -rsf . -rd "na" -s tinode.MeLoadtest +``` +Connects 10000 sessions to `me` topic for `user1` with password `user1123` over 600 seconds. + +```shell +JAVA_OPTS="-Dtopic=grpYOrcDwORhPg -Daccounts=users.csv -Dnum_sessions=10000 -Dramp=1000 -Dpublish_count=2 -Dpublish_interval=300" gatling.sh -sf . -rsf . -rd "na" -s tinode.SingleTopicLoadtest +``` +Connects 10000 users (specified in `users.csv` file) to `grpYOrcDwORhPg` topic over 1000 seconds. Each user will publish 2 messages with interval up to 300 seconds. + This will be eventually packaged into a docker container. + +### Experiments + +We have tested our single-server Tinode synthetic setup with 10000 accounts on a 2 CPU box. +As the load increases, before starting to drop: + +* The server can easily sustain 10000 concurrently connected sessions. +* An individual group topic was able to sustain 1500 concurrent sessions. diff --git a/loadtest/loadtest.scala b/loadtest/loadtest.scala index ca9553b1..9540e1e9 100644 --- a/loadtest/loadtest.scala +++ b/loadtest/loadtest.scala @@ -58,9 +58,7 @@ class Loadtest extends TinodeBase { } .exec(ws("close-ws").close) - val numUsers = Integer.getInteger("num_users", 10000) - val rampPeriod = java.lang.Long.getLong("ramp", 300L) - setUp(scn.inject(rampUsers(numUsers) during (rampPeriod.seconds))).protocols(httpProtocol) + setUp(scn.inject(rampUsers(numSessions) during (rampPeriod.seconds))).protocols(httpProtocol) } class MeLoadtest extends TinodeBase { @@ -88,9 +86,7 @@ class MeLoadtest extends TinodeBase { .pause(1000) .exec(ws("close-ws").close) - val numUsers = Integer.getInteger("num_users", 10000) - val rampPeriod = java.lang.Long.getLong("ramp", 300L) - setUp(scn.inject(rampUsers(numUsers) during (rampPeriod.seconds))).protocols(httpProtocol) + setUp(scn.inject(rampUsers(numSessions) during (rampPeriod.seconds))).protocols(httpProtocol) } class SingleTopicLoadtest extends TinodeBase { @@ -133,7 +129,5 @@ class SingleTopicLoadtest extends TinodeBase { } .exec(ws("close-ws").close) - val numUsers = Integer.getInteger("num_users", 10000) - val rampPeriod = java.lang.Long.getLong("ramp", 300L) - setUp(scn.inject(rampUsers(numUsers) during (rampPeriod.seconds))).protocols(httpProtocol) + setUp(scn.inject(rampUsers(numSessions) during (rampPeriod.seconds))).protocols(httpProtocol) } diff --git a/loadtest/tinode.scala b/loadtest/tinode.scala index 7c7eea92..55c8faaa 100644 --- a/loadtest/tinode.scala +++ b/loadtest/tinode.scala @@ -21,6 +21,10 @@ class TinodeBase extends Simulation { val publishCount = Integer.getInteger("publish_count", 10).toInt // Maximum interval between publishing messages to a topic. val publishInterval = Integer.getInteger("publish_interval", 100).toInt + // Total number of sessions. + val numSessions = Integer.getInteger("num_sessions", 10000) + // Ramp up period (0 to numSessions) in seconds. + val rampPeriod = java.lang.Long.getLong("ramp", 300L) val hello = exitBlockOnFail { exec {