warehouse-scale computing
with mesos anD SINGULARITY
I work in the PaaS Team
we Implement & maintain:
Internet Scale Services / SaaS
microservices
"...the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery" - Martin Fowler
POLYGLOT PERSISTENCE
THE TWELVE-FACTOR APP
The hubspot way
Speed wins → Speed Product Development
Teams X Microservices X Data Stores → a ton of servers / VMs
welcome to the cluster management pains
The hubspot case - pre-mesos
219 WEB SERVICES
246 WORKERS
205 SCHEDULED JOBS
173 ON-DEMAND
~1150 small to medium size AWS servers
and lots of productivity lost in provisioning & operations
statically partition your cluster is bad
and can cost much...
Mesos to the rescue
Mesos key features
Grid computing & mesos
Mesos architecture
mesos resource offers
mesos primitives
--resources="cpus(prod):20; cpus(stage):4; mem(*): 24000;
disk(*):128000; ports(*):[30000-32000]; disks(*):{1,2,3,4}
--attributes="disktype:ssd; dc:1; rack:2; netcard:10G; os:ubuntu; jvm:8u45"
mesos strong ecosystem
An Essential Singularity exp(1/z)
HubSpot Singularity
PRE & POST-MesoS SOME FACTS & NUMBERS
HUbspot mesos QA cluster
(Singularity DASHBOARD)
HUBSPOT MESOS PROD CLUSTER
(SINGULARITY DASHBOARD)
Why WE BUILT singularity
why WE BUILT singularity
HUBSPOT PAAS
DEPLOY CONFIGURATION
name: Orion_All_Deployable_Types_In_One_Config
buildName: MesosDeployIntegrationTestsProject
type: procfile
owners:
- user@hubspot.com
appRoot: /testservice/v1
loadBalancers:
- test
env:
all:
JOB_JAR: TestJob.jar
procfile:
webService:
cmd: java $JVM_DEFAULT_OPTS -jar TestService.jar server $CONFIG_YAML
instances: 2
cpus: 2
memory: 1024
numRetriesOnFailure: 5
scheduledJob:
cmd: java $JVM_DEFAULT_OPTS -jar $JOB_JAR -testjob
schedule: '*/3 * * * *'
numRetriesOnFailure: 5
healthcheckIntervalSeconds: 40
healthcheckTimeoutSeconds: 40
worker:
cmd: java $JVM_DEFAULT_OPTS -jar TestDaemon.jar
daemon: true
onDemand:
cmd: java $JVM_DEFAULT_OPTS -jar TestsDaemon.jar
daemon: false
servers:
qa:
- mesos:
prod:
- mesos
SINGULARITY COMPONENTS
singularity Scheduler
A DEPLOY-CENTRIC REST API to:
-
register deployable items
-
execute their deploys
-
view sandbox files
- get metadata / historical data
SINGULARITY SCHEDULER Advanced features
Automatic Rollback of failed deploys
Key Singularity abstractioNs
Deployable (SINGULARITY REQUEST object)
{ "id": "TestService", "owners": [ "feature_x_team@mycompany.com", "developer@mycompany.com" ], "type": service, "instances": 3, "rackSensitive": true, "loadBalanced": true }
KEY SINGULARITY ABSTRACTIONS
singularity deploy object
{ "requestId": "MDS_TestService", "id": "71_7", "customExecutorCmd": ".../singularity-executor", "resources": { "cpus": 1, "memoryMb": 896, "numPorts": 3 }, "env": { "DEPLOY_MEM": "768", "JVM_MAX_HEAP": "384m", },
"executorData": { "cmd": "java -Xmx$JVM_MAX_HEAP -jar .../TestService.jar server $CONFIG_YAML",
"embeddedArtifacts": [ { "name": "rawDeployConfig", "filename": "TestService.yaml", "content": "bmFtZT..." } ], "externalArtifacts": [], "s3Artifacts": [ { "name": "executableSlug", "filename": "TestService.tar.gz", "md5sum": "313be85c5979a1c652ec93e305eb25e9", "filesize": 81055833, "s3Bucket": "hubspot.com", "s3ObjectKey": "build_artifacts/.../TestService.tar.gz" } ],
Singularity Executor
advanced Slave services
SINGULARITY UI
SINGULARITY UI - Deployable item list
SINGULARITY UI - DEPLOYABLE ITEM
SINGULARITY UI - historical TASK
A mesos/singularity cluster at your laptop
% git clone https://github.com/HubSpot/Singularity.git
% cd Singularity
% docker-compose up
% boot2docker ip
192.168.59.103
point you browser to http://192.168.59.103:7099/singularity/
Exampe Singularity request aPI calls
http GET http://192.168.59.103:7099/singularity/api/requests
http POST http://192.168.59.103:7099/singularity/api/requests id=TestWorker owners:='["gchomatas@hubspot.com"]' requestType=worker
http POST http://192.168.59.103:7099/singularity/api/deploys deploy:='{"requestId":"TestWorker", "id":"1", "command":"while true; do echo \"Spending cycles for nothing\"; sleep 2; done", "resources": {"cpus":0.1, "memoryMb":128, "numPorts":0}}'
DEPLOY A JOB WITH DEFAULT EXECUTOR
http POST http://192.168.59.103:7099/singularity/api/requests id=TestJob owners:='["gchomatas@hubspot.com"]' requestType=scheduled schedule='* 0/5 * * * ?'
http POST http://192.168.59.103:7099/singularity/api/deploys deploy:='{"requestId":"TestJob", "id":"1", "command":"echo \"Spending cycles for nothing\"", "resources": {"cpus":0.1, "memoryMb":128}}'
Deploy a service with default executor
http POST http://192.168.59.103:7099/singularity/api/requests id=TestService owners:='["gchomatas@hubspot.com"]' requestType=service
http POST http://192.168.59.103:7099/singularity/api/deploys deploy:='{"requestId":"TestService", "id":"1", "command":"java -Ddw.server.applicationConnectors[0].port=$PORT1 -Ddw.server.adminConnectors[0].port=$PORT0 -jar helloworld-1.0-SNAPSHOT.jar server example.yml", "resources": {"cpus":0.1, "memoryMb":128, "numPorts":2}, "uris":["https://github.com/micktwomey/docker-sample-dropwizard-service/releases/download/1.0/helloworld-1.0-SNAPSHOT.jar", "https://github.com/micktwomey/docker-sample-dropwizard-service/releases/download/1.0/example.yml"], "healthcheckUri": "/healthcheck"}'
DEPLOY A Docker SERVICE WITH Docker EXECUTOR
http POST http://192.168.59.103:7099/singularity/api/requests id=TestDockerService owners:='["gchomatas@hubspot.com"]' requestType=service
http POST http://192.168.59.103:7099/singularity/api/deploys deploy:='{"requestId":"TestDockerService", "id":"1", "resources": {"cpus":0.1, "memoryMb":128, "numPorts":2}, "healthcheckUri": "/healthcheck", "containerInfo":{"type": "DOCKER", "docker":{"network": "BRIDGE", "image": "micktwomey/sample-dropwizard-service:1.0", "portMappings":[{"containerPortType": "LITERAL", "containerPort": 8081, "hostPortType": "FROM_OFFER", "hostPort": 0, "protocol": "tcp"}, {"containerPortType": "LITERAL", "containerPort": 8080, "hostPortType": "FROM_OFFER", "hostPort": 1, "protocol": "tcp"}]}}}'
http POST http://192.168.59.103:7099/singularity/api/deploys deploy:='{"requestId":"TestDockerService", "id":"2", "resources": {"cpus":0.1, "memoryMb":128, "numPorts":2}, "healthcheckUri": "/healthcheck", "containerInfo":{"type": "DOCKER", "docker":{"network": "BRIDGE", "image": "micktwomey/docker-sample-web-service", "portMappings":[{"containerPortType": "LITERAL", "containerPort": 8081, "hostPortType": "FROM_OFFER", "hostPort": 0, "protocol": "tcp"}, {"containerPortType": "LITERAL", "containerPort": 8080, "hostPortType": "FROM_OFFER", "hostPort": 1, "protocol": "tcp"}]}}}'
DEPLOY A Load Balanced SERVICE with Default executor
http POST http://192.168.59.103:7099/singularity/api/requests id=TestLoadBalancedService owners:='["gchomatas@hubspot.com"]' requestType=service loadBalanced=true
http POST http://192.168.59.103:7099/singularity/api/deploys deploy:='{"requestId":"TestLoadBalancedService", "id":"1", "command":"java -Ddw.server.applicationConnectors[0].port=$PORT0 -Ddw.server.adminConnectors[0].port=$PORT1 -jar helloworld-1.0-SNAPSHOT.jar server example.yml", "resources": {"cpus":0.1, "memoryMb":128, "numPorts":2}, "uris":["https://github.com/micktwomey/docker-sample-dropwizard-service/releases/download/1.0/helloworld-1.0-SNAPSHOT.jar", "https://github.com/micktwomey/docker-sample-dropwizard-service/releases/download/1.0/example.yml"], "healthcheckUri": "/", "serviceBasePath":"/", "loadBalancerGroups":["test"]}'
Develop with singularity
useful links
Examples of using the API
Try it out in your laptop!
MesoCon 2014 Continuous Deployment with Singularity
Twitter University: Mesos, HubSpot, and the Singularity
Mesosphere Case Studies: HubSpot Experiences with Apache Mesos
APPENDIX
SINGULARITY API
Manage Deployable items
ENDPOINT: /requests
register / update / unregister an item
get info about an item
list items in active | paused | cool-down state
run / restart / pause / un-pause an item
SINGULARITY API
Deploy the Deployable Items
ENDPOINT: /deploys
deploy an already registered item
cancel a pending deploy
SINGULARITY API
Manage Deployable item Instances (TASKS)
ENDPOINT: /tasks
get the list of all scheduled tasks (not yet active)
get scheduled tasks for a specific item
list tasks in active | cleaning | lbcleanup state
info about a specific task
active tasks in a slave
Kill a task
SINGULARITY API
Historical Information about deployable items & their tasks
ENDPOINT: /history
a single task history
tasks that have run in the past
all previous item updates
search for historical items by item id
all item deploys
a specific item deploy
SINGULARITY API
List & Download files in Active Task Sandbox
ENDPOINT: /sandbox
list all task files
read file chunks
download a file
SINGULARITY API
Cluster STATE Information
ENDPOINT: /state
{
activeTasks: 567,
activeRequests: 843,
cooldownRequests: 1,
scheduledTasks: 142,
pendingRequests: 0,
lbCleanupTasks: 1,
activeSlaves: 21,
deadSlaves: 0,
decomissioningSlaves: 0,
activeRacks: 3,
deadRacks: 0,
futureTasks: 142,
maxTaskLag: 0,
overProvisionedRequests: 0,
underProvisionedRequests: 0,
allRequests: 844
}
SINGULARITY UI - DEPLOYABLE ITEM task
SINGULARITY ui - dashboard
SINGULARITY UI - racks & slaves
Warehouse-scale computing with Mesos and Singularity: PaaS Infrastructure Automation and sustainable development velocity
By Gregory Chomatas
Warehouse-scale computing with Mesos and Singularity: PaaS Infrastructure Automation and sustainable development velocity
Use mesos and singularity to automate infrastructure, remove service deployment frictions and sustain the development velocity of your product
- 3,499