- Create user.
- Login.
- Create poll.
- Delete poll.
- Vote in poll.
- View poll.
- List polls.
POST api/users- Parameters in body:
{username: string, password: string}. - Returns 200 when user is created, with the following information in the response body -
{access_token: jwt, token_type: "bearer"}. - Returns 404 if user already exists.
- Parameters in body:
POST api/login- Parameters in body:
{username: string, password: string} - Returns 200 when credentials are valid, with the following information in the response body -
{access_token: <jwt>, token_type: "bearer"}. - Returns 401 if credentials are invalid (unauthorized).
- Parameters in body:
POST api/polls- Parameters in headers:
Authorization: Bearer <jwt> - Parameters in body:
{title: string, options: string[]} - Returns 200 when credentials are valid, with the following information in the response body -
{id: ID}. - Returns 401 if credentials are invalid (unauthorized).
- Parameters in headers:
POST api/polls/:poll_id/vote?option={option_id}- Parameters in headers:
Authorization: Bearer <jwt> - Returns 200 if vote is successful.
- New vote: records vote.
- Same vote in same option: cancels previous vote in option.
- Vote in different option: cancels previous vote and records new vote in new option.
- Returns 401 if credentials are invalid (unauthorized).
- Returns 400 if option is invalid.
- Parameters in headers:
GET api/polls/{id}- Returns 200 with poll details in response body -
{id: num, title: string, options: {name: string, votes: num}[]}. - Returns 404 if poll with received ID does not exist.
- Returns 200 with poll details in response body -
GET api/polls/- Returns 200 with list of polls -
{polls: {id: num, title: string}[]}.
- Returns 200 with list of polls -
DELETE api/polls/{id}- Parameters in headers:
Authorization: Bearer <jwt> - Returns 200 with ID of deleted poll -
{id: ID}when credentials are valid and user is creator. - Returns 401 if credentials are invalid (unauthorized).
- Returns 403 if user making request is not poll creator.
- Parameters in headers:
Authentication is done using JWT.
Artillery was used as the platform to perform mixed load and stress tests on the server. The test scheme is as follows:
- Artillery generates a user and assigns them a role of "pollster" with a probability of 5%, or voter, with a probability of 95%
- In both cases, the user registers and obtains a JWT
- The pollster publishes a survey randomly selected from a predefined set of surveys
- The voter randomly chooses a survey to vote on, and votes for an option, also randomly
The number of users per second generated by Artillery gradually increases, starting at one user per second, up to 70 users per second
The goal of these tests is not to completely saturate the system, but to evaluate scalability under a reasonable load. However, in some of the languages used, this load manages to saturate the system. In these cases, the tests were stopped before reaching the final stage, as it makes no sense to evaluate the language beyond its limit.
The complete test script can be found here
- Measurements
- CPU usage
- Memory usage
- Latency
- Throughput
The metrics dashboard can be found here