Hello, this is Yoshida, who is the lead engineer of the team activation service "Goalous".
In this article, we will talk about how Goalous migrated from HTTP/1.1 to HTTP/2 and how it actually migrated.
Why did we migrate?
Until last month, we had spent more than a month and a half making large-scale performance improvements to the entire service.
Goalous has been quite noticeable for its poor response for a long time, and many people have commented that the display speed is slow. As a development team, we wanted to reduce user stress and improve the experience of using the service, and we wanted to make it work crisply, but we couldn't get started because adding and improving functions was a priority.
However, we really wanted to respond before charging for the service, so in May of this year, we decided to work on improving the overall performance of the service with all our team's efforts. The move to HTTP/2 is one of its performance improvements. I will omit the details of the benefits of HTTP/2 this time, but if you want to know more, please refer to here.
We decided to move to HTTP/2 because we wanted to reap the benefits of request and response multiplexing, and there was another important reason for us. That's an AWS problem.
Goalous uses OpsWorks on AWS, a configuration management service for configuring and operating applications in the cloud enterprise using Chef.
OpwsWorks is a great addition to the OpsWorks stack and OpsWorks for Chef AutomateGoalous uses the OpsWorks stack.
The OpsWorks stack is clearly differentiated by the Chef version 11 or 12. We've been using the Chef11 stack for a long time, but we wanted to upgrade to Chef12 soon, so this HTTP2/migration was a good opportunity.
Also, I couldn't use HTTP/2 unless the load balancer was ALB and not ELB, so I decided to take the plunge and create a completely new stack of Chef12+ALB.
How did we migrate?
Unfortunately, Goalous's Chef recipe cannot be published, so this article will focus on how to configure Opsworks' Chef12 stack and ALB to achieve HTTP/2, and will explain the steps for a minimalist configuration using a sample Chef recipe.
Reference: Use Application Load Balancers with your AWS OpsWorks Chef 12 Stacks
Step1.ALB Creation
Basically, it is created according to the official AWS documentation.
However, skip step 5: Target target groups. Instance creation and target registration in target groups are performed in OpsWorks.
Step2.Creating an OpsWorks Stack
On the OpsWorks dashboard page, click the Add Stack button.

After transitioning to the Add Stack page, first select Chef12 Stack,
- Stack name
- Region
- VPC
- Default subnet
- Default operating system
- Default SSH key
Enter each of them.

Next, select Yes under Use custom Chef cookbooks in the red frame to specify the Git repository for the sample Chef recipe mentioned above.
- Repository type: Git
- Repository URL: https://github.com/awslabs/opsworks-example-cookbooks
After entering, click the Add Stack button in the bottom right corner to confirm that the stack has been added.

Step3.Grant Permissions to the ELB API
You can skip it if the profile you selected in the Default IAM instance profile already has ELB API-related permissions.
Select the Stack you created in Step 2. The detailed information of the stack is displayed, and you can click the link for the registered profile in the red frame of the Default IAM Instance Profile in the Advanced Option group.

On the role details page, click the Create Role Policy button.

Select a custom policy and proceed to the next step.

Enter a policy name and paste the following JSON to grant ELB API permissions to complete policy enforcement.

Step4.Layer creation
After selecting the Stack you created, click the Layer tab in the left menu and click the Add Layer link (or the Add button in the upper right corner).

Enter any string in Name and Short name to complete the creation.

Linking ALB Target Groups to the OpsWorks Stack
Point As of August 2017, ALB does not yet support the configuration of load balancers in the OpsWorks stack. Therefore, the linking of the stack to the ALB must be done in the Chef recipe.
Click on the Setting link for the created Layer.

In the General Settings tab, there is an item called Custom Json. Now, you will link the ALB target group created in Step 1 with the OpsWorks stack.

The template for the Custom JSON is listed below. Paste this JSON inside the text area of the Custom Json.
Next, replace the target_group_arn value with the ARN string of the target group of the ALB created in Step 1. To check the ARN of a target group, select the target group from the left menu in the EC2 console, and then select the target group created in Step 1. At the bottom of the screen, you will see detailed information about the target group, and there is an ARN field in it, so copy and paste the value string into the Custom Json above to save the settings.

Setting Up Chef Recipes to Run
Go to the Recipes tab and save the settings by assigning the recipe to a lifecycle event as follows: - Setup: alb_support::install_http_server,alb_support::attach_to_alb recipe - Shutdown: alb_support::d etach_from_alb,alb_ Added recipe for support::uninstall_http_server
*This is just a sample for realizing HTTP/2 requests using ALB in OpsWorks. In fact, I think that the installation of web servers such as Apache and Nginx is built into other recipes, so in that case, alb_support::install_http_server,alb_support::uninstall_http_server is no need.

Adding EC2 Instances - Checking HTTP/2 Requests
Select Instances from the left menu in OpsWorks, then add an instance.

Launch the instance you added.

After successful launch, access the domain associated with ALB in Route53. It's an HTTP/2 request!

How to incorporate it into a real project
In this article, we have covered the use of a sample recipe to check for HTTP/2 requests in the Chef12+ALB stack. However, when using this in a real project,
- What to do in the Chef12 stack because the community cookbook is no longer automatically imported when running a recipe
- How to automatically generate recipes to be referenced in stacks in dev and stage environments
There are many issues.
I plan to write about solving these issues in the next article as a practical edition, so please wait a while.