Skip to main content

How to run the JIT in a multi instance AWS environment

This how-to describes how to configure JIT to run on AWS with auto-scaling functionality. It is the best way of deploying JIT for use with many simultaneous users as it can scale depending on usage.

Initially a light-weight orchestrator instance is started. The orchestrator instance launches a new JIT instance, if no idle JIT instance is available, to service the JIT stream when a browser makes a request to play a file. This allows for large scale deployments with many simultaneous users.

Prerequisites

  • To use this you need access to a jit-orchestrator and a jit-instance-agent AMI. Your sales representative will provide this access.
  • To verify the installation https://sdk.accurate.video can be used. Your sales representative will provide this access.
  • Make sure Terraform is installed
  • Login to your AWS account in a shell
  • Make sure that the Orchestrator Image is tagged with:
    Environment=<insert environment here. Default Prod. If changed it needs to be passed to terraform as a variable aswell>
    Role=jit-orchestrator
  • Make sure that the Instance-Agent image is tagged with:
    Environment=<insert environment here. Default Prod. If changed it needs to be passed to terraform as a variable aswell>
    Role=jit-agent

Download the template

Clone or download the JIT Deployment Examples repository and cd to the terraform/aws directory

This repository contains README, and template files, required to get up and running with JIT.

git clone https://gitlab.com/accurate-player/jit-deployment-examples.git
cd jit-deployment-examples/terraform/aws

Apply the Terraform

Find the latest JIT version in the release notes: https://docs.accurate.video/docs

terraform init
terraform apply -var "target_version=<insert version here>"

The JIT service is, after the apply, available on the link provided by the Terraform output jit_url

Example Output
...

Outputs:

agent = {
"iam_profile_name" = "jit-agent-instance-profile-Dev"
"security_group_id" = "sg-0123456789abcdef0"
}
jit_url = "http://203.0.113.55:8080"
key_pair_name = "jit-key-Dev"
orchestrator = {
"iam_profile_name" = "jit-orchestrator-instance-profile-Dev"
"instance_id" = "i-0abcd1234eff56789"
"instance_public_ip" = "203.0.113.55"
"security_group_id" = "sg-0987654321fedcba0"
}
ssh_private_key_path = "/home/user/git/artifacts/jit-key-Dev.pem"
ssh_to_jit = "ssh -o 'StrictHostKeyChecking no' -o 'IdentitiesOnly=yes' -i /home/user/git/artifacts/jit-key-Dev.pem ubuntu@203.0.113.55"

Configuration

For possible configuration parameters see variables

Verify JIT installation

  • Navigate to https://sdk.accurate.video/accurate-player-demo/test-your-content
  • Important since SSL isn't configured yet for JIT you need to allow mixed content for the site
  • If using Chrome
    • Click the Lock icon (or "Not Secure" warning) on the far left of the address bar
    • Click Site Settings
    • Scroll down to the "Insecure content" permission
    • Change the dropdown from Block (default) to Allow
    • Close the settings tab and Refresh the page
  • Select "Stream type" jit
  • In the "JIT URL" field enter the jit_url provided by the Terraform apply
  • Click "LOAD VIDEO"
  • If the installation was successful a demo video should now start playing

Shutdown and cleanup

Execute the following command to delete the session service's EC2 instance and all associated AWS resources:

terraform destroy -var "target_version=<insert version here>"

If destroy fails

If the destroy fails, it is likely that JIT instances (started by the orchestrator, not Terraform) haven't been terminated. These instances are using a resource created by Terraform, preventing Terraform from deleting the resource. The error will look something like this:

Error: deleting Security Group (sg-0123456789abcdef0): operation error EC2: DeleteSecurityGroup, https response error StatusCode: 400, RequestID: e2a29962-d063-4ebb-b370-9da3f2eceab4, api error DependencyViolation: resource sg-0123456789abcdef0 has a dependent object

To resolve this do the following

  • Log into the AWS console in a web browser
  • Important Ensure you have selected the correct Region in the top right corner (the same region where you deployed Terraform)
  • Navigate to the EC2 service
  • Click Instances
  • In the search bar, filter for instances named JIT-instance-
  • Select any instances that are not already in the state Terminated.
  • Click the Instance State dropdown and select Terminate (delete) instance. Confirm the deletion in the popup prompt
  • Wait until the instances reach the Terminated state
    • Note: You may need to click the refresh icon in the EC2 console to see the state update
  • Run terraform destroy again

Next steps

Now you have deployed the JIT backend in "multi instance" mode with the default settings. Do you want to