LTH-image

Homework Assignment 2

Home Assignment 2

Overview

This assignment is divided into two parts, and will build further upon the cloud application you created in home assignment 1. The goal of this homework is to make you familiar with with Platform-as-a-Serivce (PaaS) and how it differs from Infrastructure-as-a-Service (IaaS), which you worked with in homework 1.

You will extend the cloud application by adding a web server, so that the clients can access it through their browsers (part 1). Then you will make it elastic and scalable by creating auto scaling and load balancing for both the back-end and the front-end of your cloud application (part 2). The back-end consists of the SQS-queues, the S3-bucket and the EC2Instances (= what you did in homework 1) and the front-end is what you will develop in this homework.

The PaaS that you will work with during this homework is the Amazon Beanstalk.

Once again there are various ways to do this homework. Amazon Beanstalk supports Java, .NET, PHP, Python, Ruby, and Docker. However, I will only give details on how to do it using Eclipse, Java (.jsp), and Apache Tomcat. But please, feel free to do it in whatever way you wish, as long as you meet the requirements.

Deadline and Deliverables

The deadline for this homework is the session 3 (3/3). Before then you should hand in:

  • A zip-file containing your workspace and code.
  • Short text describing the difference of what a PaaS and a IaaS is (about 1/4 - 1/2 page).
    • We would like to get your perspective on the difference.

Part 1 - Creating a Web Server

Part 1 of this homework will focus on creating a web server for the cloud application, so that users/clients can access it from their web browsers. The Web Server will replace the Client in the previous homework. Therefore most of the code developed for the Client in homework 1 can be reused. The new structure for the cloud application can be seen below:

Requirements

The requirements for the web-server is as follows:

  • The web server should be hosted using Amazon Beanstalk
  • The functionality should be the same as for the Client-Application in home assignment 1:
    • User inputs a comma-separated list of numbers
    • Puts this list in the S3-bucket (and remembers the key/pointer to this object).
    • Puts a message in the SQS-inbox with a key/pointer to the object in the S3-bucket, along with the process to be executed on these numbers.
    • Waits until a response is generated in the SQS-outbox (which should contain a pointer to the new, and processed, object in the S3-bucket along with the process executed).
    • Reads the result from the S3-bucket
    • Prints the results along with the original numbers, and the process that was executed.
    • Deletes the result-message from the SQS-outbox.

Again the available processes should be:

  • Min
  • Max
  • Product
  • Sum
  • Sum-of-squares

Remember that you might now serve several users simultaneously, and therefore it will be extra important that you figured out a clever way to relate the correct user-request with the correct response in the previous homework. Also, there is no need for a fancy GUI here, some good ole’ fashioned text boxes will do just fine..

A Natural Working Order

To make the testing and development easier, and faster, I suggest that you make it possible to have a local host on your computer. Thus you can test your web server locally before you upload it to Amazon Beanstalk, much like how you tested the EC2Instance-Code locally in the homework 1. When running on a local host-server you will still be able to connect to the back-end of your cloud application.

  1. Get familiar with AWS Beanstalk
  2. Create a sample Java Web Application
  3. Create your Web Server
  4. Test it locally and make sure it works
    • Remember to have your EC2Instances (and SQS-queues and S3-bucket) up and running when you do
  5. Deploy it to AWS Beanstalk
    • Make sure that you choose Single Instance Web Server = no auto scaling, no load balancing
    • We will use auto scaling and load balancing later
  6. Log into the AWS Management Console
    • How many EC2Instances is running now?
    • How many S3-bucket do you have now?

Part 2 - Auto Scaling and Load Balancing

Now that you have your brand new cloud application up and running you need to do something to meet the extreme user demands it will face once it becomes the new killer app! Luckily this is easy, you just have to create auto scaling for your EC2Instances and load balancing and auto scaling for your web server. Some useful links for this can be found below.

  1. Log into your AWS Management Console
  2. Go to your EC2 Dashboard
  3. Create a Launch Configuration under Auto Scaling -> Launch Configurations
    • Choose the AMI you created during Homework 1
    • If you did as we asked (for security reasons) and removed it earlier, you will have to create it again :)
  4. Create a Auto Scaling Group under Auto Scaling -> Auto Scaling Group
    • Make sure to use `Scaling Policies
    • Minimum Instances: 2
    • Maximum Instances: 4
    • Desired Instances: 3
    • Add 1 instance when load is > 60 %
    • Remove 1 instance when load is < 5 %
  5. Go and see how your instances are doing, and how many you have
    • Try to terminate one and see what happens
  6. Go to your Elastic Beanstalk Dashboard
  7. Go to your web application
  8. Under Scaling:
    • Enable Load Balancing, autoscaling
    • Minimum Instances: 2
    • Maximum Instances: 4
  9. Go back to your EC2 Dashboard
  10. How many Autoscaling groups do you have now?
  11. How many EC2 Instances are running?
  12. Which was the easiest to set up load balancing and autoscaling for?

Some useful links for part 2: