fbpx

Home assignment

  1. Create a private github repository
  2. Create docker file for this application and deploy containers using docker compose:
    1. Nginx official (not plus or any other image) load balancer container that will listen on port 80 and route traffic to applications, do not usee ip_hash in the nginx conf.
    2. the application will run on 3 replica containers. The logs generated by the application are required to be retained so that they can be accessed after the container is stopped. The application will be written using python. Assume you already have code for this application (next task).
    3. DB container. The data and logs of the database container are required to be retained so that they can be accessed after the container is stopped.
  3. push all your source to the github repository.
  4. Write a Python server web app. The application have 2 routes:
    1. Route: “/” :
      • Adding +1 to a global counter, and saving it to the DB.
      • Create a cookie for 5 minutes with the value of the internal IP.
      • Record the date and time, the client’s IP address, and its own internal IP address in a MySQL table named  access_log.
      • Return to the browser: internal IP address of the server.
    2. Route: “/showcount”
      • Return to the browser: The global counter number
  5. Run this application under app containers (docker).
  6. Create a bash script to change the scale for the container apps to 5. (scale up\down)
  7. Push all your source to the github repository.
  8. Using a cookie from the app, create a stickiness engine in your nginx load balancer (once you get a response from one server, stay on this server for 5 minutes). 
  9. Push all your source to the github repository.

How to test your project

  1. open developer toolbar
  2. go to application\storage
  3. go to cookie
  4. see the cookie you created with the internal IP of the container
  5. check that the is is like 172.X.X.3-9 (usually) and it’s the same IP you see in the browser.
  6. Refresh, the IP in the browser stick to you! (do it more than once).
  7. Delete the cookie and refresh – now see that the IP changed.
  8. do 6-7 again.

After home assignment + test, contact me on whatsapp to schedule zoom.