Create aprrank Stack

h1. Request Details

h2. Background

Accom ranking platform is a set of instruments that are used to rank a set of hotels/inventory. In the future, ideally all ranking-related functions/services will reside in Accom ranking platform.

Design Document (jump to Accom-level implementation section): https://docs.google.com/document/d/1EYaSJbeJiQOgT14A-G6l8izvuhkA8oNlOIdNQGHV_io

h2. Purpose

aprrank is Accom Ranking Platform's main ranking service.
This service acts as the main actor to various hotel ranking functions (ranking, rank simulation, etc.).

h2. Impact

From engineering point of view, this would decouple ranking-related functions from HINV (there are currently to many things done in HINV) as what has been described in "Purpose".

From business point of view, the instances requested in this ticket would later be used to enable a new hotel ranking process with more capabilities than we currently have.

h2. Risk

No direct risk as this is a new stack.

Once used, this will increase aprwp's load as most ranking process would be orchestrated by aprwp (workflow platform).

h2. Resources

h3. ELB

h4. Configuration

{code}
name = "aprrank-lbint-01"
internal = "true"
cross_zone_load_balancing = "true"
idle_timeout = "60"
connection_draining = "true"
connection_draining_timeout = "300"

listener = {
instance_port = "61055"
instance_protocol = "HTTP"
lb_port = "443"
lb_protocol = "HTTPS"
}

health_check = {
healthy_threshold = "10"
unhealthy_threshold = "2"
target = "HTTP:61055/healthcheck"
interval = "30"
timeout = "5"
}

tags = {
Name = "aprrank-lbint-01"
Service = "aprrank"
ProductDomain = "apr"
Team = "ACT - Demand"
Environment = "production"
Description = "Internal load balancer for Accom ranking service"
}
{code}

h4. CLB Attachment

h4. CNAME record

h3. EC2

h4. Configuration

{code}
count = "12"
instance_type = "c4.2xlarge"
ebs_optimized = "false"
disable_api_termination = "false"

root_block_device = {
volume_type = "gp2"
volume_size = "8"
delete_on_termination = "true"
}

tags = {
Service = "aprrank"
Cluster = "aprrank-app"
ProductDomain = "apr"
Team = "ACT - Demand"
Application = "java-7"
Environment = "production"
Description = "Backend application service for Accom ranking service"
}
{code}

h3. ElastiCache Memcached

h4. Configuration

{code}
cluster_id = "aprrasr-memcached"
engine = "memcached"
engine_version = "1.4.x"
maintenance_window = "Mon18:18:00-Mon19:19:00"
node_type = "r3.xlarge"
num_cache_nodes = "3"
port = "11211"
parameter_group_name = "default.memcached1.4"
apply_immediately = "false"
az_mode = "cross-az"

tags = {
Name = "aprrasr-memcached"
Service = "aprrank"
ProductDomain = "apr"
Team = "ACT - Demand"
Environment = "production"
Description = "Cache for storing ranked list of hotels"
}
{code}

h3. Postgres RDS

h4. Purpose

Postgres RDS would be used to store business rulesets. PostgreSQL is chosen as currently ruleset DB accessors only exists for using MongoDB and PostgreSQL for the database.

As current plan, the data stored would be sensitive to hoteliers as the data reflect how we determine ranking treatments/rules for all users' search requests.

The absence/data inconsistency of this DB would affect how we rank search results. Loss of data/unavailability would hamper our ability to provide business-critical ranking process as most probably we would fallback to use unoptimized ranking process.

The DB would be accessed by:

The data stored inside the DB isn't migrated from Mongo as the features/services that will use the DB are new.

h4. Risk

If an unauthorized person accesses the DB, our rules used to rank hotels will be known and may be abused by hoteliers to leverage their position in search result.

As mentioned above, DB unavailability/loss of data would result in hampered ranked search result generation.

h4.Configuration

{code}
name = "aprrank-postgres-01"
allocated_storage = "4"
allow_major_version_upgrade = "false"
auto_minor_version_upgrade = "true"
backup_retention_period = "7"
backup_window = "17:00-19:00"
engine_version = "9.5.7"
instance_class = "db.m3.medium"
maintenance_window = "Mon20:20:00-Mon20:20:30"
vpc_security_group_ids = ""

tags = {
Name = "aprrank-postgres-01"
Service = "aprrank"
ProductDomain = "apr"
Team = "ACT - Demand"
Environment = "production"
Description = "Database to store Accom ranking related data"
}
{code}

h3. DynamoDB

h4. Purpose

Used to store service configurations of services residing in aprrank. For example, config for feature control.

As it would be used only to store configs, the usage (access) won't be high as each config would be cached locally in each utilizing services.

h4. Configuration

{code}
table_name = "aprrank-dynamo"
read_capacity_units = "1"
write_capacity_units = "1"
primary_partition_key = "id"
ttl_attribute = "disabled"
{code}

h2. Related Request(s)