Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Best Practices for Scaling and Deploying Couchbase Mobile in the Cloud: Couchbase Connect 2015

2,235 views

Published on

If you are designing an app with Couchbase Mobile there are many factors that can impact its performance and scalability. This session provides guidance for scaling out your Couchbase Mobile cluster and deploying your mobile database in the cloud. Additionally, Traun will take you through several different deployment approaches and show you how easy and automated the deployment process can be for Couchbase Mobile.

Published in: Technology
  • Be the first to comment

Best Practices for Scaling and Deploying Couchbase Mobile in the Cloud: Couchbase Connect 2015

  1. 1. BEST PRACTICES FOR SCALING AND DEPLOYING COUCHBASE MOBILE IN THE CLOUD Traun Leyden, Couchbase
  2. 2. ©2015 Couchbase Inc. ‹#› Couchbase Mobile Overview Couchbase Server Couchbase Server Couchbase Server Sync Gateway Sync Gateway Sync Gateway Sync Gateway Couchbase Lite (iOS, Android, PhoneGap, etc.)
  3. 3. ©2015 Couchbase Inc. ‹#› Couchbase Mobile Overview Couchbase Server Couchbase Server Couchbase Server Sync Gateway Sync Gateway Sync Gateway Sync Gateway Couchbase Lite (iOS, Android, PhoneGap, etc) Share Nothing
  4. 4. ©2015 Couchbase Inc. ‹#› Couchbase Mobile Overview Couchbase Server Couchbase Server Couchbase Server Sync Gateway Sync Gateway Sync Gateway Sync Gateway Couchbase Lite (iOS, Android, PhoneGap, etc) Share Nothing Sync Gateway Scale Horizontally
  5. 5. ©2015 Couchbase Inc. ‹#› Couchbase Mobile Overview Couchbase Server Couchbase Server Couchbase Server Sync Gateway Sync Gateway Sync Gateway Sync Gateway Couchbase Lite (iOS, Android, PhoneGap, etc) Share Nothing Scale Horizontally Couchbase Server
  6. 6. Scaling Challenges
  7. 7. ©2015 Couchbase Inc. ‹#› Clients Will Keep Long Running Sockets Open Sync Gateway Couchbase Lite (iOS, Android, PhoneGap, etc.) WebSocket HTTP Long Polling
  8. 8. ©2015 Couchbase Inc. ‹#› WebSocket and HTTP Long-Polling Clients Android allows background apps to keep sockets open longer TCP keepalive considerations Clients tend to leave half-open connections Dead peers can live up to 2 hours before being cleaned up by the TCP/IP stack It’s possible to tune this — see our Sync Gateway Docs under “OS Level Tuning”
  9. 9. ©2015 Couchbase Inc. ‹#› Couchbase Views Sync Gateway uses 8 Couchbase views Couchbase views are relatively expensive operations The Couchbase Server documentation provides specific guidelines regarding view performance Couchbase views can pose scalability challenges
  10. 10. Scaling Best Practices
  11. 11. ©2015 Couchbase Inc. ‹#› Sizing Considerations 5K connected users per Sync Gateway on a quad-core machine That number depends on many factors: How often users connect How powerful your hardware is Whether custom views are used (note: requires more cores) How many view queries are triggered These numbers are gross approximations; do your own testing Recommended number of users per Sync Gateway
  12. 12. ©2015 Couchbase Inc. ‹#› Use a Load Balancer to Distribute Load Couchbase Server Sync Gateway Couchbase Lite (iOS, Android, PhoneGap, etc.) Load Balancer Sync Gateway Sync GatewaySync Gateway Couchbase Server Couchbase Server
  13. 13. ©2015 Couchbase Inc. ‹#› Load Balancer Considerations The load balancer can pick any Sync Gateway; there are no “sticky sessions” to worry about Nginx is known to work with Sync Gateway Amazon Elastic Load Balancer (ELB) is known to have WebSocket issues
  14. 14. ©2015 Couchbase Inc. ‹#› Multiple Datacenter Considerations Couchbase XDCR (Cross Datacenter Replication) only works in a master-slave scenario In general, it’s not safe to mutate a Couchbase bucket that is updated by Sync Gateway In a master-master scenario, the Couchbase bucket owned by Sync Gateway would be updated in an unsafe manner, and is therefore not a valid usage scenario sg-replicate (experimental – alpha) can work in a master- master scenario, because it speaks the Sync Gateway replication protocol and all changes go through Sync Gateway
  15. 15. A Tour of Our New Performance Testing Suite
  16. 16. ©2015 Couchbase Inc. ‹#› The Problem Testers need to spin up large, ephemeral clusters for performance testing Testing teams need their own cluster without interfering with other teams With dedicated clusters, many of the servers are frequently idle, which has cost implications. The performance test suite should work on: Various cloud providers (AWS, GCE, etc.) Bare-metal clusters No common performance testing suite has been available for everyone to share and contribute to, resulting in duplicated effort
  17. 17. ©2015 Couchbase Inc. ‹#› We want you to use this tool! Save time/effort by doing your own internal performance testing using this tool instead of building your own Make it easy for us to reproduce your issue under identical conditions Contribute back any scenarios specific to your use cases, for possible inclusion into the common performance testing suite
  18. 18. ©2015 Couchbase Inc. ‹#› Components of the Performance Test Suite AWS CloudFormation – Machine Provisioning (AWS Specific) Ansible – Software Provisioning Gateload or Gatling – load generators Splunk – Monitoring and Analysis (optional)
  19. 19. ©2015 Couchbase Inc. ‹#› AWS CloudFormation Allows you to compactly specify a group of EC2 instances and their settings via a single JSON file You can launch or destroy a CloudFormation cluster in single operation You can easily automate operations via the EC2 command line interface tool CloudFormation is available in the AWS Management Console Features
  20. 20. ©2015 Couchbase Inc. ‹#› Ansible Ansible is an automated provisioning tool, like Chef and Puppet No agents are required – therefore there are no “bootstrapping” conundrums Uses a declarative approach via easy-to-read YAML files – there is no “code” to maintain Easy for people to pick up and make changes, even non- programmers 100% open source – it has 11K stars and 3K forks on GitHub It can run on either cloud or on-premises clusters Features
  21. 21. ©2015 Couchbase Inc. ‹#› Spin up an AWS CloudFormation Determine the custom parameters that you want Number of Couchbase Server instances Number of Sync Gateway instances Number of Gateload or Gatling instance Instance type for all of the above AMI for all of the above (defaults to stock CentOS 7 AMI) Generate a CloudFormation JSON file via the troposphere python script, using the parameters given above Launch CloudFormation via the AWS CLI tool or AWS Management Console
  22. 22. ©2015 Couchbase Inc. ‹#› Provision the Cluster via Ansible ansible-playbook install-go.yml && ansible-playbook install-couchbase-server-3.0.3.yml && ansible-playbook build-sync-gateway.yml && ansible-playbook build-gateload.yml && ansible-playbook install-sync-gateway-service.yml && ansible-playbook install-splunkforwarder.yml
  23. 23. ©2015 Couchbase Inc. ‹#› Sample Ansible Playbook (YAML) - name: Stop Couchbase Service service: name=couchbase-server.service state=stopped ignore_errors: yes - name: Uninstall couchbase server shell: rpm -e couchbase-server ignore_errors: yes - name: Remove all couchbase server residue shell: rm -rf /opt/couchbase - name: Download couchbase server get_url: url={{ couchbase_server_centos_ee_url }} dest=/tmp - name: Install Couchbase Server yum: name=/tmp/{{ couchbase_server_centos_ee_package }} state=present - name: Restart Couchbase Service service: name=couchbase-server.service state=restarted
  24. 24. ©2015 Couchbase Inc. ‹#› Result of the Ansible Provisioning Couchbase Server Couchbase Server Couchbase Server Sync Gateway Sync Gateway Sync Gateway Sync Gateway Gatling Gatling Gatling Gatling
  25. 25. ©2015 Couchbase Inc. ‹#› Gathering Performance Metrics Load generator output Gatling built-in HTML reporting Gateload JSON report Sync Gateway statistics endpoint (JSON) Couchbase Server REST API for statistics (JSON) Splunk Management Console (optional) We are working on a re-usable Splunk dashboard Gather performance metrics from several places
  26. 26. ©2015 Couchbase Inc. ‹#› Contributions Wanted We would like your help to make the Ansible scripts work on: Google Compute Engine Joyent Cloud Bare-metal clusters (the easiest) If you develop custom Gatling scenarios for your usage, please contribute them back
  27. 27. Monitoring Sync Gateway
  28. 28. ©2015 Couchbase Inc. ‹#› Monitoring Checklist Response time of root database endpoints, check for errors localhost:4985/_dbname Memory Usage via Top GC times via expvars (or logs if GODEBUG=gctrace=1) Number of Goroutines via expvars Number of open socket file descriptors netstat Keep your eye on our Splunk configuration scripts for new additions
  29. 29. Cutting Edge Approaches to Cloud Deployment
  30. 30. ©2015 Couchbase Inc. ‹#› Kubernetes Open-source container orchestration platform from Google Supports Docker and rkt (Rocket) containers Runs on-cloud (GKE, AWS, etc.) or on-premises Commercial support available from: CoreOS Tectonic (come see the talk at 1:45 pm!) Kismatic Developer momentum is off the charts Still under active development
  31. 31. ©2015 Couchbase Inc. ‹#› Joyent Triton Container-centric infrastructure-as-a-service (IaaS) Supports Docker containers Hosts are abstracted away Runs on the Joyent Public Cloud or on-premises Commercial support available from Joyent Allows you to leverage the ZFS filesystem and the DTrace profiling tools
  32. 32. ©2015 Couchbase Inc. ‹#› Cloud Foundry from Pivotal Developed to deploy the Cloud Foundry platform-as-a-service (PaaS) Can provision and deploy software over hundreds of VMS Runs on infrastructure-as-a-service (IaaS) providers such as: AWS | OpenStack | VMware vSphere Google Compute Engine | Apache CloudStack Unifies release engineering, deployment, and lifecycle management Allows you to easily version, package, and deploy software in a reproducible manner
  33. 33. ©2015 Couchbase Inc. ‹#› Links Performance Test Suite https://github.com/couchbaselabs/perfcluster-aws Couchbase on Kubernetes https://github.com/couchbase/kubernetes Couchbase on Joyent Triton http://tleyden.github.io/blog/2015/05/05/running-couchbase-
  34. 34. Thank you.

×