Skip to content

Commit

Permalink
Merge pull request mozmeao#202 from limed/200-timeout
Browse files Browse the repository at this point in the history
Set origin timeout to 120s and gunicorn timeout to 118 (seconds)
  • Loading branch information
limed committed Feb 20, 2019
2 parents 5797fd2 + 9700aeb commit 68dc1f8
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 54 deletions.
@@ -1,4 +1,3 @@

locals {
log_bucket = "${var.distribution_name}-logs"
}
Expand Down Expand Up @@ -28,7 +27,7 @@ resource "aws_s3_bucket" "logging" {
}

transition {
days = "${var.glacier_transition_days}"
days = "${var.glacier_transition_days}"
storage_class = "GLACIER"
}

Expand All @@ -43,11 +42,10 @@ resource "aws_s3_bucket" "logging" {
Service = "MDN"
Purpose = "Cloudfront logging bucket"
}

}

resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {
count = "${var.enabled}"
count = "${var.enabled}"

aliases = "${var.aliases}"
comment = "${var.comment}"
Expand Down Expand Up @@ -107,8 +105,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {
viewer_protocol_policy = "redirect-to-https"

forwarded_values {
headers = ["Host"]
query_string = true
headers = ["Host"]
query_string = true
query_string_cache_keys = ["t"]

cookies {
Expand All @@ -132,7 +130,7 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {
viewer_protocol_policy = "redirect-to-https"

forwarded_values {
headers = ["Host"]
headers = ["Host"]
query_string = false

cookies {
Expand All @@ -156,7 +154,7 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {
viewer_protocol_policy = "redirect-to-https"

forwarded_values {
headers = ["Host"]
headers = ["Host"]
query_string = false

cookies {
Expand All @@ -181,7 +179,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -204,7 +203,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -227,7 +227,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -250,7 +251,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -273,7 +275,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -296,7 +299,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -319,7 +323,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -342,7 +347,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -365,7 +371,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -388,7 +395,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -411,7 +419,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -434,7 +443,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -457,10 +467,10 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["Host", "Accept-Language"]
headers = ["Host", "Accept-Language"]

cookies {
forward = "whitelist"
forward = "whitelist"
whitelisted_names = ["django_language", "dwf_contrib_beta", "dwf_sg_task_completion", "sessionid"]
}
}
Expand All @@ -482,9 +492,10 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["Host", "Accept-Language", "X-Requested-With"]
headers = ["Host", "Accept-Language", "X-Requested-With"]

cookies {
forward = "whitelist"
forward = "whitelist"
whitelisted_names = ["django_language", "sessionid"]
}
}
Expand All @@ -506,9 +517,10 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["Host", "Accept-Language", "X-Requested-With"]
headers = ["Host", "Accept-Language", "X-Requested-With"]

cookies {
forward = "whitelist"
forward = "whitelist"
whitelisted_names = ["django_language"]
}
}
Expand All @@ -530,9 +542,10 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["Host", "Accept-Language", "X-Requested-With"]
headers = ["Host", "Accept-Language", "X-Requested-With"]

cookies {
forward = "whitelist"
forward = "whitelist"
whitelisted_names = ["django_language"]
}
}
Expand All @@ -554,7 +567,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -577,7 +591,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -600,7 +615,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -623,7 +639,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -646,7 +663,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -669,7 +687,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -692,7 +711,8 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["*"]
headers = ["*"]

cookies {
forward = "all"
}
Expand All @@ -712,10 +732,10 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {

forwarded_values {
query_string = true
headers = ["Host", "Accept-Language"]
headers = ["Host", "Accept-Language"]

cookies {
forward = "whitelist"
forward = "whitelist"
whitelisted_names = ["django_language", "dwf_contrib_beta", "dwf_sg_task_completion", "sessionid"]
}
}
Expand All @@ -729,7 +749,7 @@ resource "aws_cloudfront_distribution" "mdn-primary-cf-dist" {
http_port = "80"
https_port = "443"
origin_protocol_policy = "https-only"
origin_read_timeout = 60
origin_read_timeout = "${var.origin_read_timeout}"
origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
origin_keepalive_timeout = 5
}
Expand Down
Expand Up @@ -28,3 +28,7 @@ variable "cloudfront_log_cookies" {
variable "cloudfront_log_prefix" {
default = ""
}

variable "origin_read_timeout" {
default = "60"
}
21 changes: 11 additions & 10 deletions apps/mdn/mdn-aws/infra/modules/mdn-cdn/mdn_cdn.tf
@@ -1,20 +1,21 @@
provider "aws" {
region = "${var.region}"
region = "${var.region}"
}

########################################
# Primary CDN
########################################

module "primary-cloudfront" {
source = "./cloudfront_primary"
enabled = "${var.enabled * var.cloudfront_primary_enabled}"
distribution_name = "${var.cloudfront_primary_distribution_name}-${var.environment}"
environment = "${var.environment}"
comment = "MDN Primary ${var.environment} CDN"
acm_cert_arn = "${var.acm_primary_cert_arn}"
aliases = [ "${var.cloudfront_primary_aliases}" ]
domain_name = "${var.cloudfront_primary_domain_name}"
source = "./cloudfront_primary"
enabled = "${var.enabled * var.cloudfront_primary_enabled}"
distribution_name = "${var.cloudfront_primary_distribution_name}-${var.environment}"
environment = "${var.environment}"
comment = "MDN Primary ${var.environment} CDN"
acm_cert_arn = "${var.acm_primary_cert_arn}"
aliases = ["${var.cloudfront_primary_aliases}"]
domain_name = "${var.cloudfront_primary_domain_name}"
origin_read_timeout = "120"
}

########################################
Expand All @@ -28,6 +29,6 @@ module "cloudfront-attachments" {
distribution_name = "${var.cloudfront_attachments_distribution_name}-${var.environment}"
comment = "MDN ${var.environment} Attachments CDN"
acm_cert_arn = "${var.acm_attachments_cert_arn}"
aliases = [ "${var.cloudfront_attachments_aliases}" ]
aliases = ["${var.cloudfront_attachments_aliases}"]
domain_name = "${var.cloudfront_attachments_domain_name}"
}
2 changes: 1 addition & 1 deletion apps/mdn/mdn-aws/k8s/Makefile
Expand Up @@ -37,7 +37,7 @@ export KUMASCRIPT_SERVICE_PROTOCOL ?= TCP
export WEB_NAME ?= web
export WEB_REPLICAS ?= 1
export WEB_GUNICORN_WORKERS ?= 4
export WEB_GUNICORN_TIMEOUT ?= 120
export WEB_GUNICORN_TIMEOUT ?= 118
export WEB_GUNICORN_WORKER_MAX_REQUESTS ?= 1000
export WEB_GUNICORN_WORKER_MAX_REQUESTS_JITTER ?= 200
export WEB_CPU_LIMIT ?= 2
Expand Down
2 changes: 1 addition & 1 deletion apps/mdn/mdn-aws/k8s/regions/germany/prod.mm.sh
Expand Up @@ -46,7 +46,7 @@ export KUMASCRIPT_SERVICE_PROTOCOL=TCP
export WEB_NAME=web
export WEB_REPLICAS=1
export WEB_GUNICORN_WORKERS=8
export WEB_GUNICORN_TIMEOUT=120
export WEB_GUNICORN_TIMEOUT=118
export WEB_CPU_LIMIT=4
export WEB_CPU_REQUEST=500m
export WEB_MEMORY_LIMIT=6Gi
Expand Down
2 changes: 1 addition & 1 deletion apps/mdn/mdn-aws/k8s/regions/oregon/prod.mm.sh
Expand Up @@ -46,7 +46,7 @@ export KUMASCRIPT_SERVICE_PROTOCOL=TCP
export WEB_NAME=web
export WEB_REPLICAS=20
export WEB_GUNICORN_WORKERS=8
export WEB_GUNICORN_TIMEOUT=120
export WEB_GUNICORN_TIMEOUT=118
export WEB_CPU_LIMIT=4
export WEB_CPU_REQUEST=500m
export WEB_MEMORY_LIMIT=6Gi
Expand Down

0 comments on commit 68dc1f8

Please sign in to comment.