Skip to content

pipiobjo/compare-programming-languages

Repository files navigation

Compare Languages

Introduction

This repo should provide an easy way to check different programming languages for their performance. To make this comparable all of them have to implement the same rest api. Description see below.

All the different services will be deployed to our local k8s with limited resources.

If they are deployed successfully some basic api tests will be executed and afterwards load test will be executed to the rest api.

To provide an kubernetes this repo uses the kubernetes playground project https://github.com/pipiobjo/k8s-playground

Add a new service / programming language

  • Create a new folder for your service

    • Follow the pattern [language]-[framework]-[additional-identifiers]

      • For example java-pure-tomcat or java-springboot-jetty

  • Place your build script in the build-scripts folder

    • Use java-pure-build-deploy.sh as template

  • K8s manifests are generated via kustomize

    • The scripts expecting a k8s folder with a kustomization.tpl.yaml

      • This file is used to update the docker image version and is then copied to kustomization.yaml

      • The kustomization.yaml file is deleted after build to keep the git repo clean

      • Please use myapp as image name in your kustomize deployment resource this will automatically be replaced with the real image name

  • Add starting load test script for your service

    • Use java-pure-load-tests.sh as sample

    • load test reports should be placed in load-test-reports

  • if everything is working please create an PR for the repo

if you want to copy and existing k8s config consider using

grep -rl oldserviceName . | xargs sed -i 's/oldserviceName/newserviceName/g'

grep -rl java-pure . | xargs sed -i 's/java-pure/golang-chi/g'

Load Test

The provided load test scripts using k6s https://k6.io/docs/

REST API

User List
curl -s localhost:8080/api/user | jq
[]
Create User
curl -s --header "Content-Type: application/json" \
  --request POST \
  --data '{"login":"xyz","password":"xyz","firstname":"john", "lastname":"smith"}' \
  http://localhost:8080/api/user | jq
{
  "id": "12395c7b-d545-4fb8-90ea-bd37e73310b7"
}
Creating the same login twice results in HTTP/1.1 400 Bad Request
curl -v --header "Content-Type: application/json" \
  --request POST \
  --data '{"login":"xyz","password":"xyz", "firstname":"john", "lastname":"smith"}' \
  http://localhost:8080/api/user | jq

< HTTP/1.1 400 Bad Request
< Date: Wed, 02 Nov 2022 23:06:26 GMT
< Transfer-encoding: chunked
< Content-type: application/json

"user already exists"
Creating a second user
curl -v --header "Content-Type: application/json" \
--request POST \
--data '{"login":"abc","password":"abc","firstname":"john", "lastname":"do"}' \
http://localhost:8080/api/user | jq
User List, reduced properties are listed, without internal id and password
curl -s http://localhost:8080/api/user | jq
[
  {
    "login": "abc",
    "firstName": "john",
    "lastName": "do"
  },
  {
    "login": "xyz",
    "firstName": "john",
    "lastName": "smith"
  }
]
User List, search api for "login" / "firstname" and "lastname"
curl -s http://localhost:8080/api/user\?login\=abc | jq
[
  {
    "login": "abc",
    "firstName": "john",
    "lastName": "do"
  }
]
Get the greeting message via basic auth
curl -s http://abc:abc@localhost:8080/api/greeting | jq
{
  "msg": "Hello john do!",
  "firstname": "john",
  "lastname": "do"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published