Want to try out MongoDB on your laptop? Execute a single command and you have a lightweight, self-contained sandbox; another command removes all trace when you're done. Need an identical copy of your application stack in multiple environments? Build your own container image and then your entire development, test, operations, and support teams can launch an identical clone environment.
Containers are revolutionizing the entire software lifecycle: from the earliest technical experiments and proofs of concept through development, test, deployment, and support. Orchestration tools manage how multiple containers are created, upgraded and made highly available. Orchestration also controls how containers are connected to build sophisticated applications from multiple, microservice containers.
This webinar introduces the concepts behind containers and orchestration, then explains the available technologies and how to use them with MongoDB. Finally, you will see a demonstration of exactly how to create a MongoDB replica set on Docker and Kubernetes within the Google Cloud.
2. Agenda
1. What are containers?
2. Containers vs. VMs
3. Business benefits
4. Docker – The most popular container technology
5. Microservices
6. Orchestration
7. Security
8. MongoDB considerations
9. Implementing a MongoDB Replica Set
10.Use Cases
11.Resources
3. Containers
Real world shipping containers
• Same container efficiently transports goods by
road, rail and sea
• Contents remain untouched through all those
environments; no repacking needed
• Ubiquitous and standardized
• Simple to use – open, fill, close
• Contents of each container safe from the others
• Know how much space the container consumes
4. Containers
Software containers
• Build an image containing the full application stack
only once
• Spin up many containers from the same image in
multiple environments
– Laptop, data center, cloud
– Development, QA, production, support
• Simple to use & efficient
• Contents of each container isolated from the
others
– Storage, memory, CPU, namespace
• Constrain resources available to each container
5. Sounds like a Virtual Machine?
• Both technologies allow you to create an image and then spin up multiple, isolated
instances
• But
– Each VM contains full operating system, libraries… With containers these can be
shared
• Faster, less memory, less storage, spin up in seconds
• Run many container on a single host
– Enables microservices
• Each container has a narrow, specialized focus with well defined interfaces with
other containers
– Developer-focused tools and management APIs
• Integrate with automation systems such as Chef and Puppet
• Used by DevOps to cover entire software lifecycle
6. VM VMVM
VMs Containers
Bare Metal
Host Operating System
Hypervisor
Guest OS
Libraries
Apps
Service
Guest OS
Libraries
Apps
Service
Guest OS
Libraries
Apps
Service
Container ContainerContainer
Bare Metal
Host Operating System
Docker Engine
Libraries
Libraries
Apps
Libraries
Apps
Service ServiceService
7. Containers – Business Benefits
• DevOps & Continuous Delivery
– Low impact & risk; update one container at a time
• Replicating environments
– Instantiate clones for development, QA, production, support…
• Accurate Testing
– Confident your stack exactly matches what’s in production
• Scalability
– Add and remove containers based on demand
• Isolation
– Safely run multiple environments on the same hosts
• Performance
– Minimal impact from container overhead
• High Availability
– Redundancy from multiple containers fulfilling a role
8. Docker
The most popular container technology
• Simple to use and has a rich ecosystem
• 100,000+ images available from Docker Hub
– Including mongo hub.docker.com/_/mongo/
– Syncs with GitHub projects
• Define new images built upon base images
• Define interfaces between containers
• LINUX only (on OS X & Windows, transparently runs in
a VM)
• Runs on bare metal, VMs and cloud. Cloud providers
supply the Docker infrastructure (e.g. Google Container
Engine)
docker run -d mongo
9. Microservices
Microservices built by combining multiple
containers
• Build sophisticated services from many small,
focused processes (containers)
– Well defined APIs between components
– Each component can use different libraries,
middleware & programming languages
• Modular, decoupled architecture simplifies
maintenance and enables reuse
• Fault tolerant
• Scalable
Cmglee
10. Orchestration
Automated deployment, connecting and
maintenance of multiple containers
• Provision hosts
• Instantiate containers
• Reschedule failed containers
• Link containers through defined interfaces
• Expose services to the outside world
• Scale out and back in
11. Orchestration Technologies
• Docker Machine
– Provisions hosts and installs Docker Engine
– Used to run Docker on Windows and OS X
• Docker Swarm
– Provides single, virtual Docker host by clustering multiple Docker hosts
– Often uses Docker Machine
• Docker Compose
– Deploys multi-container applications; including dependencies
– Targets development, testing, and staging environments
12. Orchestration – Kubernetes
Created by Google, feature-rich and widely
adopted
• Automated container deployment and ‘replication’
• On-line scale out/in
• Rolling upgrades
• HA – automatic rescheduling of failed containers
• Exposure of network ports to external apps
• Load balancing over groups of containers
providing a service
• Provided as a service by Google Compute Engine
13. Orchestration – Kubernetes
Terms
• Cluster: collection of nodes (bare-metal servers or
VMs)
• Pod: group of containers and volumes collocated in the
same host. Containers share namespace & IP address
• Volume: map ephemeral directories within container to
external, persistent storage
• Service: Load balancer and ambassador for containers
– exposes port and external IP address
• Labels: used to tag resources; labels are then
referenced from other resources using selectors
• Replication Controller: ensures the requested number
of containers are always running
14. Orchestration – Apache Mesos
Designed to scale to 10,000s of physical
servers; used by Twitter, Airbnb & Apple
• Developer writes code to turn application into a
framework to run on Mesos
• Less feature rich than Kubernetes; considers many
functions such as load balancing, rescheduling,
and scaling to be a higher level function
– Project exists to run Kubernetes as a Mesos
framework
• Foundation for distributed systems
– Apache Aurora, Chronos, Marathon
15. Choosing an Orchestration Framework
Factors to consider…
• Integration with existing DevOps frameworks?
• Number of hosts?
• Bare metal, VMs or cloud deployment?
• Automated High Availability?
• Grouping and load balancing?
• Existing skills?
• Install your own orchestration framework or use as
a service?
16. Security
Containers provide opportunities to improve
security
• Containers provide isolation; resources can only
be accessed from outside through explicitly
provided APIs
• Resources can be rationed
• A container’s role can be very narrow – remove
anything not required
• Images and containers should be kept current;
rolling upgrades with Kubernetes or Aurora
• Typically log into container as root so restrict
access
17. MongoDB
Orchestrating MongoDB containers requires
special treatment as it’s a distributed,
stateful application…
• State should survive rescheduling; use
Kubernetes’ volumes abstraction
• Replica Set members must communicate with
each other; expose external IP addresses/ports
which survive rescheduling
• Replica Set must be initialized from exactly one
member
• MongoDB must still be monitored and backed up –
MongoDB Cloud Manager
22. Square Enix: DaaS
• Multi-tenant OnLine Suite
• DaaS to studios & developers, exposed as
an API
• Manages data shared by all gaming titles
– Player profiles
– Credits
– Leaderboards
– Competitions
– Catalog
– Cross-platform messaging
API Layer
App Layer
MongoDB Shared Data Service
On-Prem Private Cloud
23. Square Enix: Public Cloud
API Layer
App Layer
MongoDB Shared Data Service
On-Prem Private Cloud
• In-App functionality provisioned to private clusters on
AWS
– Game state
– Player metrics
– Game-specific content & features
• Elastically scalable
24. Square Enix:
MongoDB Cloud Manager
API Layer
App Layer
MongoDB Shared Data Service
On-Prem Private Cloud
Run entire estate
with just 2 x admins
25. Resources
• Case Study – FuboTV
https://www.mongodb.com/blog/post/leaf-in-the-wild-leading-
soccer-streaming-service-fubotv-scales-its-business-with-
mongodb-docker-containers-and-kubernetes
• Case Study – Square Enix
https://www.mongodb.com/blog/post/leaf-in-the-wild-square-
enix-scales-tomb-raider-hitman-absolution-deus-ex-and-
more-on-mongodb
• “Enabling Microservices – Containers &
Orchestration Explained” white paper
https://www.mongodb.com/collateral/microservices-
containers-and-orchestration-explained
Hinweis der Redaktion
[Apache Aurora](http://aurora.apache.org/) – a highly scalable service scheduler for long-running services and `cron` jobs; it's used by Twitter. Aurora extends Mesos by adding rolling updates, service registration, and resource quotas.
[Chronos](https://github.com/mesos/chronos) – a fault tolerant service scheduler, to be used as a replacement for `cron`, to orchestrate scheduled jobs within Mesos.
[Marathon](https://mesosphere.github.io/marathon/) – a simple to use service scheduler; it builds upon Mesos and Chronos by ensuring that two Chronos instances are running.
[Apache Aurora](http://aurora.apache.org/) – a highly scalable service scheduler for long-running services and `cron` jobs; it's used by Twitter. Aurora extends Mesos by adding rolling updates, service registration, and resource quotas.
[Chronos](https://github.com/mesos/chronos) – a fault tolerant service scheduler, to be used as a replacement for `cron`, to orchestrate scheduled jobs within Mesos.
[Marathon](https://mesosphere.github.io/marathon/) – a simple to use service scheduler; it builds upon Mesos and Chronos by ensuring that two Chronos instances are running.
[Apache Aurora](http://aurora.apache.org/) – a highly scalable service scheduler for long-running services and `cron` jobs; it's used by Twitter. Aurora extends Mesos by adding rolling updates, service registration, and resource quotas.
[Chronos](https://github.com/mesos/chronos) – a fault tolerant service scheduler, to be used as a replacement for `cron`, to orchestrate scheduled jobs within Mesos.
[Marathon](https://mesosphere.github.io/marathon/) – a simple to use service scheduler; it builds upon Mesos and Chronos by ensuring that two Chronos instances are running.
[Apache Aurora](http://aurora.apache.org/) – a highly scalable service scheduler for long-running services and `cron` jobs; it's used by Twitter. Aurora extends Mesos by adding rolling updates, service registration, and resource quotas.
[Chronos](https://github.com/mesos/chronos) – a fault tolerant service scheduler, to be used as a replacement for `cron`, to orchestrate scheduled jobs within Mesos.
[Marathon](https://mesosphere.github.io/marathon/) – a simple to use service scheduler; it builds upon Mesos and Chronos by ensuring that two Chronos instances are running.
90% of the configuration is the same, with just these changes:
The disk and volume names must be unique and so `mongodb-disk2` and `mongo-persistent-storage2` are used
The Pod is assigned a label of `instance: jane` so that the new service can distinguish it (using a selector) from the `rod` Pod
The Replication Controller is named `mongo-rc2`
The Service is named `mongo-svc-b` and gets a unique, external IP Address (in this instance, Kubernetes has assigned `104.1.5:2701`)
Because we’re using external IP addresses, we can instead create the replica set with nodes in different regions
Square eni – host some of world’s most popular games
Moved online in 2007, using SQL Server, by 2011 hit scalabiliuty limits, to support both in-gaming operations and analytics
multi-tenant Online Suite – a central shared infrastructure. deliver MongoDB-as-a-Service to all of our studios and developers. provide an API that allows the studios to use MongoDB to store and manage metrics, player profiles, info cast information, leaderboards and competitions. Messaging across all supported platform such as PlayStation, Xbox, PC, web, iOS, and Android etc. Essentially, the Online Suite supports any functionality that is needed across multiple games. 10 shard cluster
Every title also needs to support its own specific in-game functionality, and so each is provisioned with dedicated infrastructure connected to MongoDB to store game state and player metrics, along with specific content and features. Can be up to 50 nodes, - need elastic scalability – as game is launched, new marketing promos. All deployed to AWS across regions
All managed by Cloud Manager – automatically provisons new instances, upgrades, monitoring, backup
Every title also needs to support its own specific in-game functionality, and so each is provisioned with dedicated infrastructure connected to MongoDB to store game state and player metrics, along with specific content and features. Can be up to 50 nodes, - need elastic scalability – as game is launched, new marketing promos. All deployed to AWS across regions
All managed by Cloud Manager – automatically provisons new instances, upgrades, monitoring, backup
All managed by Cloud Manager – automatically provisons new instances, upgrades, monitoring, backup