PerfAnalytics.API is a restful API which saves data, posted from PerfAnalytics.JS and returns time specific filtered data. Application is deployed to Heroku and could be found on api-perf-analytics.herokuapp.com.
- Getting Started
- Building the Project
- Running the Tests
- Environment Variables
- API Endpoints and Documentations
- Contact Information
- License
-
MongoDB v4.4 or higher -> mongoDB Installation Page
-
Node v12 or higher (with npm) -> Node.js Downloads Page
-
Yarn Package Manager -> Install yarn with npm:
npm install -g yarn
-
Docker v3.3.2 or higher (optional) -> Docker Get Started Page
Before starting the application, fork/download/clone this repo. There are two different ways to run the application:
- Build the docker image with the following code:
./docker-build.sh # for mac users
./docker-build.bat # for windows users
- To run the application on localhost:8080:
docker-compose up -d --build
- To stop the application:
docker-compose stop
- Install the required dependencies:
yarn install
- To run the application in dev mode on localhost:5000:
yarn run dev
- To run the application with the production build on localhost:5000:
yarn build # producing a production build
cp -r src/swagger dist/src # copy swagger config to dist
yarn start # running the server
- To create an optimized production build:
npm run build
or
yarn build
- To run the unit tests:
npm test
or
yarn test
- To run the load tests:
npm run artillary-local # use artillary-prod for heroku app
or
yarn run artillary-local # use artillary-prod for heroku app
DB_URI
: MongoDB URI. An example could be found below.
mongodb+srv://<db-user>:<db-pass>@<cluster-address>/<db-name>?retryWrites=true&w=majority
PORT
: Port of the server.
REST API endpoints documentation. For further information, you can check out the Postman Collections & Environments at postman
directory and the Swagger Documentation from /swagger
endpoint.
/metrics
endpoint can handle 266.67 requests per second on a:
- MacBook Pro (16-inch, 2019)
- Processor: 2,3 GHz 8-Core Intel Core i9
- Memory: 16 GB 2667 MHz
- Number of Processors: 1
- Total Number of Cores: 8
- L2 Cache (per Core): 256 KB
- L3 Cache: 16 MBDDR4
For further information, checkout load-testing-report.json
file.
- Description: Get Metrics from last 30 minutes or within a time range.
- Query Parameters:
startDate
: Start date of the time range. Must be in ISO8601 format. E.g. 2021-05-10T00:00:00.000ZendDate
: End date of the time range. Must be in ISO8601 format. E.g. 2021-05-10T00:00:00.000Z
{
"data": [
{
"id": string,
"url": string,
"ttfb": number,
"fcp": number,
"domLoad": number,
"windowLoadEvents": number,
"resources": [
{
"name": string
"source": string
"responseTime": number
"executionTime": number
"fetchTime": number
}
],
"timestamp": string
}
]
}
- Description: Create new Metric.
{
"url": string,
"ttfb": number,
"fcp": number,
"domLoad": number,
"windowLoadEvents": number,
"resources": [
{
"name": string
"source": string
"responseTime": number
"executionTime": number
"fetchTime": number
}
],
"timestamp": string
}
{
"id": string
}