MySQL Web Reference Architectures Best Practices for Innovating on the Web.
-
Upload
laura-stokes -
Category
Documents
-
view
216 -
download
0
Transcript of MySQL Web Reference Architectures Best Practices for Innovating on the Web.
MySQL Web Reference ArchitecturesBest Practices for Innovating on the Web
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 2
Safe Harbour Statement
The following is intended to outline our general product direction. It is
intended for information purposes only, and may not be incorporated into any
contract.
It is not a commitment to deliver any material, code, or functionality, and
should not be relied upon in making purchasing decisions. The development,
release, and timing of any features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 3
ProgramAgenda
Requirements for Web Innovation
Reference Architectures– Sizing & Topologies
– Enabling Technology
– Best Practices
Hardware Sizing
Operational Best Practices
Resources
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 4
2x DATA GROWTH EVERY 14 MONTHS
6.7BN MOBILE SUBS IN 2012
1.2 BILLION iOS & ANDROID APPS DOWNLOADED PER WEEK
85% HANDSETS SHIPPED WITH A BROWSER
$1TR BY 2014
$700BN IN 2011
2.4BN USERS
$1.7TR GLOBAL CONTRIBUTION
70+ NEW DOMAINS EVERY 60 SECONDS
350m TWEETS PER DAY875k TPM DURING US
PRESIDENTIAL ELECTION
1BN+ USERS
20M APPS PER DAY
72 HOURS UPLOADED EVERY MINUTE
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 5
Infrastructure Requirements
Agile, open & adaptableSimple & repeatableLow latencyScalable and AvailableRock-solid securityLow TCO
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 6
MySQL: Powering the Web & the Cloud
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 7
MySQL Web Reference Architectures
Best practices for innovating in web & mobile services
– Fast Time to Market
– Open, Agile and Highly Adaptable
– Reduced Cost, Risk & Complexity
On-Premise or in the Cloud
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 8
Reference Architectures: Design Patterns On-Line Retail
– Small, Medium & Large: Database load & size
– User Authentication & Session Management
– Content Management
– eCommerce
– Analytics & Big Data Integration
Social Networking– Extra Large
Recommended hardware Operational Best Practices
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 9
Reference Architecture SizingSocial Network
Small Medium Large Extra Large
Queries/Second <500 <5,000 10,000+ 25,000+
Transactions/Second <100 <1,000 10,000+ 25,000+
Concurrent Read Users
<100 <5,000 10,000+ 25,000+
Concurrent Write Users
<10 <100 1,000+ 2,500+
Database Size
Sessions <2 GB <10 GB 20+ GB 40+ GB
eCommerce <2 GB <50 GB 50+ GB 200+ GB
Analytics (Multi-Structured Data) <10 GB <1TB 10+ TB 100+ TB
Content Management (Meta-Data) <10 GB <500 GB 1+ TB 2+ TB
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 10
Reference Architectures
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 11
Small: Web Reference ArchitectureSocial Network
Small Medium Large Extra Large
Queries/Second <500 <5,000 10,000+ 25,000+
Transactions/Second <100 <1,000 10,000+ 25,000+
Concurrent Read Users
<100 <5,000 10,000+ 25,000+
Concurrent Write Users
<10 <100 1,000+ 2,500+
Database Size
Sessions <2 GB <10 GB 20+ GB 40+ GB
eCommerce <2 GB <50 GB 50+ GB 200+ GB
Analytics (Multi-Structured Data) <10 GB <1TB 10+ TB 100+ TB
Content Management (Meta-Data) <10 GB <500 GB 1+ TB 2+ TB
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 12
Small: Web Reference Architecture
Single server supporting:– Users & sessions
– eCommerce
– Content management
MySQL replication– Analytics and Backups
If traffic volumes increase, scale session management first on a separate server
Limited ScalabilityRecommended to start with the Medium Architecture
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 13
MySQL Default Storage EngineInnoDB
Data integrity: Fully ACID-compliant, crash-safe, Foreign Keys High concurrency: Row level locking, MVCC Scale up: 48+ threads, Scale-Out: MySQL replication Flexible: On-Line DDL, Full-text search, SQL & NoSQL APIs,
Backup and restore buffer pool Instrumented & Monitored: Performance_Schema, MySQL
Enterprise Monitor
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 14
MySQL Audit API– enables users to add auditing MySQL Enterprise Audit provides ready-made policy auditing
Out-of-the-box logging of connections, logins, query activity across all or specific MySQL servers
User defined policies, filtering and log rotation Dynamically enabled, disabled: no server restart XML-based audit stream per Oracle audit specification
Adds regulatory compliance to MySQL applications.HIPAA, Sarbanes-Oxley, PCI, etc.
New!MySQL Enterprise AuditPolicy-based Auditing for MySQL Applications
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 15
2. User Joe Connects and Queries Server1
MySQL Enterprise Audit Flow
1. DBA Enables on Server1Server1
3. Joe’s connection, query logged
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 16
MySQL Authentication API – enables addition of user authentication - MySQL Enterprise Security provides ready-made authentication modules
PAM (Pluggable Authentication Modules)- Access external authentication methods- Standard interface (Unix, LDAP, Kerberos, others)- proxied and non-proxied users Windows- Access native Windows services- Authenticate users already logged into Windows (Windows Active Directory)
Integrates MySQL with existing security infrastructures and SOPs.
MySQL Enterprise SecurityExternal Authentication
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 17
Online, high performance backup for InnoDB (scriptable interface) Full, Incremental, Partial Backups (with compression) Point in Time, Full, Partial Recovery options Enterprise Advisor Monitoring and Alerts on Backup Operations Metadata on status, progress, history Unlimited Database Size Cross-Platform
- Windows, Linux, UnixMEB Backup
FilesMySQL
Database Files
mysqlbackup
Ensures quick, online backup and recovery of your on premise and Cloud based MySQL applications.
MySQL Enterprise Backup
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 18
Medium: Web Reference ArchitectureSocial Network
Small Medium Large Extra Large
Queries/Second <500 <5,000 10,000+ 25,000+
Transactions/Second <100 <1,000 10,000+ 25,000+
Concurrent Read Users
<100 <5,000 10,000+ 25,000+
Concurrent Write Users
<10 <100 1,000+ 2,500+
Database Size
Sessions <2 GB <10 GB 20+ GB 40+ GB
eCommerce <2 GB <50 GB 50+ GB 200+ GB
Analytics (Multi-Structured Data) <10 GB <1TB 10+ TB 100+ TB
Content Management (Meta-Data)
<10 GB <500 GB 1+ TB 2+ TB
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 19
Medium: Web Reference Architecture
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 20
Best Practices - OverviewMedium Web Reference Architecture
Server ratio: 10 application servers to each MySQL Server– More for PHP applications, fewer for Java
– Add more slaves as the application tier scales
Caching layer deployed in session & content management components
– Memcached or Redis are common
– Reads fulfilled from cache, relieving load on the source database servers
– NoSQL Memcached APIs can enable compression of caching and data layers
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 21
Best Practices – Content ManagementMedium Web Reference Architecture
Each slave can handle around 5,000 concurrent users
Each master handles 20 slaves – More slaves are often used in larger environments
MySQL Replication for high availability & scale-out Meta data of content assets managed by MySQL Distributed File System / CDN / Cloud (i.e. S3) for
physical storage of assets on– High quality SAN (redundancy for HA)
– Across commodity nodes
XOR
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 22
Best Practices – Sessions & eCommerce Medium Web Reference Architecture
Session Management & eCommerce– Session data maintained for up to 1 hour in a dedicated partition, rolling
partitions used to delete aged data NoSQL Memcached API for InnoDB can be used to scale session management
– eCommerce HA Semi-Synchronous replication or clustering (DRBD, shared storage, etc.)
– If web traffic grows, move Session Management to MySQL Cluster Persist session data for real-time personalization of user experience 99.999% availability and in-memory data management can reduce need for DRBD
& caching
Data is captured in Analytics Database, increasingly replicated to Big Data system for analysis
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 23
MySQL HASolutions
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 24
MySQL Replication Duplicates database from a “master” to a “slave”
– Redundant copies of the data provide foundation for High Availability
– Scale out by distributing queries across the replication cluster
Master
Slaves
Web / App Servers
Writes & Reads Reads
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 25
High Availability & ScalabilityMySQL Replication
Scale-out within and across data centers Self-healing and crash-safe Multiple topologies supported
– Master/Slave, Cascading, Circular
Asynchronous as default with Semi-Synchronous as an option
Replication utilities for fast provisioning Monitoring & best practices with MySQL
Enterprise Monitor
Relay Log
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 26
MySQL 5.6: Evolving Replication
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 27
• Stricter data durability, integrity constraints– Shared storage persists commits across instances– Clustering software manages data access– Auto-failover of applications and database– Deploy with MySQL replication for slave scale-out
• MySQL Certified & Supported Solutions• Oracle VM Template• Windows Failover Clustering• Oracle Solaris Cluster
VIP
Clie
nts
Shared-Disk Clustering for HA
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 28Copyright © 2012, Oracle and / or its affiliates. All rights reserved. September 29th, 2012
Shared Nothing Clustering for HA
DRBD + Clustering– Based on distributed storage, not a SAN
– Synchronous replication eliminates risk of data loss
Open source, mature & proven Certified and fully supported by Oracle
– DRBD integrated into Oracle Linux Unbreakable Enterprise Kernel R2
– Pacemaker and Corosync for clustering / failover
– Updates to stack via ULN channel
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 29
MySQL default thread-handling – excellent performance, can limit scalability as user connections grow
Connections assigned to 1 thread for the life of the connection, same thread used for all statements
Thread Pool API, enables users to build their own thread pool MySQL Thread Pool improves sustained performance/scale as user
connections grow Thread Pool contains configurable number of thread groups, each manages up to 4096
re-usable threads Threads are prioritized, statements queued to limit concurrent executions, load on
server, improve scalability as connections grow
MySQL Enterprise ScalabilityMySQL Thread Pool
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 30
MySQL Enterprise Edition With Thread Pool
MySQL Community Server Without Thread Pool
60x Better Scalability with Thread Pool
MySQL 5.6.11 Oracle Linux 6.3, Unbreakable Kernel 2.6.32
4 sockets, 24 cores, 48 ThreadsIntel(R) Xeon® E7540 2GHz CPUs512GB DDR RAM
With Thread Pool Enabled
1 4 16 32 64 128 256 512 1024 2048 4096 81920
2000
4000
6000
8000
10000
12000
MySQL 5.6 Sysbench OLTP Read/Write
Simultaneous Database Connections
Tra
ns
ac
tio
ns
Pe
r S
ec
on
d
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 31
Large: Web Reference ArchitectureSocial Network
Small Medium Large Extra Large
Queries/Second <500 <5,000 10,000+ 25,000+
Transactions/Second <100 <1,000 10,000+ 25,000+
Concurrent Read Users
<100 <5,000 10,000+ 25,000+
Concurrent Write Users
<10 <100 1,000+ 2,500+
Database Size
Sessions <2 GB <10 GB 20+ GB 40+ GB
eCommerce <2 GB <50 GB 50+ GB 200+ GB
Analytics (Multi-Structured Data) <10 GB <1TB 10+ TB 100+ TB
Content Management (Meta-Data) <10 GB <500 GB 1+ TB 2+ TB
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 32
Large: Web Reference Architecture
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 33
MySQL Cluster: Overview
• Auto-Sharding, Multi-Master• ACID Compliant, OLTP + Real-Time Analytics
HIGH SCALE, READS + WRITES
• Shared nothing, no Single Point of Failure• Self Healing + On-Line Operations
99.999% AVAILABILITY
• Open Source + Commercial Editions• Commodity hardware + Management, Monitoring Tools
LOW TCO
• Key/Value + Complex, Relational Queries• SQL + Memcached + JavaScript + Java + JPA + HTTP/REST & C++
SQL + NoSQL
• In-Memory Optimization + Disk-Data• Predictable Low-Latency, Bounded Access Time
REAL-TIME
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 34
MySQL Cluster Architecture
MySQL Cluster Data Nodes
Clients
Application Layer
Management
Data Layer
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 35
MySQL & Hadoop Use-Case in Web Architecture
Users
Browsing
RecommendationsProfile,
Purchase History
Web Logs:Pages Viewed
Comments Posted
Social media updatesPreferences
Brands “Liked”
Recommendations
Telephony Stream
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 36
BI Solutions
ACQUIRE
ORGANIZEANALYZE
DECIDE
Applier
MySQL in the Big Data Lifecycle
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 37
New: MySQL Applier for Hadoop
Real-time streaming of events from MySQL to Hadoop
– Supports move towards “Speed of Thought” analytics
Connects to the binary log, writes events to HDFS via libhdfs library
Each database table mapped to a Hive data warehouse directory
Enables eco-system of Hadoop tools to integrate with MySQL data
See dev.mysql.com for articles Available for download now
– labs.mysql.com
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 38
10x faster read/write access to InnoDB or MySQL Cluster
Bypasses SQL parsing Fast look-ups and data
ingestion Maintain ACID guarantees Maintain SQL for complex
queries Combine with On-Line DDL for
schema evolution
NoSQL Interfaces for MySQL
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 39
Extra Large: Social Network Reference ArchitectureSocial Network
Small Medium Large Extra Large
Queries/Second <500 <5,000 10,000+ 25,000+
Transactions/Second <100 <1,000 10,000+ 25,000+
Concurrent Read Users
<100 <5,000 10,000+ 25,000+
Concurrent Write Users
<10 <100 1,000+ 2,500+
Database Size
Sessions <2 GB <10 GB 20+ GB 40+ GB
eCommerce <2 GB <50 GB 50+ GB 200+ GB
Analytics (Multi-Structured Data) <10 GB <1TB 10+ TB 100+ TB
Content Management (Meta-Data) <10 GB <500 GB 1+ TB 2+ TB
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 40
Extra Large: Social Network
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 41
Best Practices Social Networking Reference Architecture
Introduces Sharding– Implemented at the application layer for scaling very high volume of writes
– Data divided into smaller sets, distributed across low-cost hardware
– Shards based on Hash of a single column – ie. User ID “Functional” sharding also an option
Sharding only needed in a small percentage of workloads– MySQL scale-up, coupled with replication will get users a long way!
– Most Web and mobile workloads are still read-intensive, ie record is read before updates applied
– MySQL Cluster supports Auto-Sharding + Cross-Shard JOINs
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 42
Sharding Implementation
Master
Slave
Clie
nts
Slaves
Shards
Reads
Writes
Partitioning Logic
11 22 33 44 55
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 43
Recommended Hardware
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 44
Up to 64 x86-64 bit CPU threads (MySQL 5.6 and above). Recommended RAM at least equal to or larger than “hottest” (most
regularly accessed) data set. Linux, Oracle Solaris or Microsoft Windows operating systems. Minimum of 4 x SSDs or HDDs. 8 – 16 drives will increase
performance for I/O intensive applications.– Hardware RAID with battery-backed cache.
– RAID 10 recommended. RAID 5 is suitable if the workload is read-intensive.
2 x Network Interface Cards and 2 x Power Supply Units for redundancy.
The Perfect MySQL Server
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 45
MySQL Cluster Hardware Selection - SQL Layer
• 4 - 24 x86-64 bit CPU threads• Minimum 4GB of RAM
• Memory not as critical at this layer• Requirements influenced by connections and buffers.
• 2 x Network Interface Cards & 2 x PSUs• Linux, Solaris or Windows operating systems.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 46
MySQL Cluster Hardware Selection - Data Layer
• Up to 64 x86-64 bit CPU threads• Use high frequency: enables faster processing of messages
• Calculating RAM per Data Node (in-memory database)• Database Size * # Replicas * 1.25 / # data node• 50GB database * 2 replicas * 1.25 / 2 data nodes = 64GB of RAM • Non-indexed columns can be stored on disk, reduces RAM
requirements
• 2 x NICs and 2 x PSUs• Deep-dive into network best-practices in Ref Archs Guide
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 47
Entry-Level Mid-Range High-End
1 x SATA 7200 RPM• For read-mostly• No redundancy
(but other data node isthe mirror)
1 x SAS 10K RPM or SSD• Heavy duty (many MB/s)• No redundancy
(but other data node is the mirror)
4 x SAS 10-15K RPM or SSDs• Heavy duty (many MB/s)• Disk redundancy (RAID1+0),
hot swap
• REDO, LCP, BACKUP – written sequentually in small chunks (256KB) • If possible, use Odirect = 1
LCPREDOLOG
LCPREDOLOG LCP / REDOLOG
MySQL Cluster Hardware Selection:Disk Subsystem for Checkpointing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 48
Recommended Minimum High-End Recommendation
2 x SAS 10K RPMor 2 x SSD
• Use High-End Recommendation for heavy read / write workloads• (1000's of 10KB records per sec) of data (i.e. Content Delivery platforms)
• Having TABLESPACE on separate disk is good for read performance • Enable WRITE_CACHE on devices
TABLESPACE
LCPREDOLOGUNDOLOG
UNDOLOG
LCP(REDO LOG / UNDO LOG)
TABLESPACE 1
TABLESPACE 2
4 x SAS 10-15K RPM or SSD
(REDO LOG)(REDO LOG)
MySQL Cluster Hardware Selection:Disk Data Storage
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 49
Operational Best Practices
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 50
Oracle Premier Lifetime Support
Oracle Product Certifications/Integrations
MySQL Enterprise High Availability
MySQL Enterprise Security
MySQL Enterprise Scalability
MySQL Enterprise Backup
MySQL Enterprise Monitor/Query Analyzer
MySQL Workbench
MySQL Enterprise EditionHighest Levels of Security, Performance and Availability
MySQL Enterprise Audit
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 51
A Virtual MySQL DBA Assistant!
Web-based, global view of MySQL/Cluster applications (on-premise and Cloud deployments)
Automated, rules-based monitoring and alerts (SMTP, SNMP enabled)
Query capture, monitoring, analysis and tuning, correlated with Monitor graphs
Real-time Replication Monitor with auto-discovery of master-slave topologies
Integrated with Oracle Support
MySQL Enterprise Monitor
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 52
Saves time writing, deploying, versioning, maintaining custom scripts. 10 Advisors, 160+ Rules, 60+ MySQL, OS specific Graphs
AdministrationMonitors and Advises on
Optimal Start up and Run time Configuration
SecurityMonitors and Advises on
Unplanned Security Changes/Loopholes
UpgradeMonitors and Advises on
Bugs/Upgrades that affect current installation
ReplicationMonitors and Advises on
Master/Slave Latency
Memory UsageMonitors and advises on
optimal memory/cache settings
SchemaMonitors and Advises on
Unplanned Schema Change
PerformanceMonitors and Advises on
Optimal Performance Variable Settings
Built by DBA to Enforce Organization specific best practices
Custom
MySQL ClusterMonitors and Advises on
status/ performance of MySQL Cluster Data Nodes
BackupMonitors and Advises on
Backup/Recovery processes
Automated Advisors and Alerts
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 53
Centralized monitoring of queries without Slow Query Log, SHOW PROCESSLIST;
Aggregated view of query execution counts, time, and rows
Visual “grab and go” correlation with Monitor graphs
Enabled via Connectors (PHP, JDBC, .Net) or MySQL Proxy
Saves you time parsing atomic executions from logs. Finds problems you cannot find yourself.
MySQL Query Analyzer
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 54
MySQL Cluster ManagerEnhancing DevOps Agility, Reducing Downtime
Self-HealingAutomated Management HA Operations
• Start / Stop node or whole cluster
• On-Line Scaling
• On-Line Reconfiguration
• On-Line Upgrades
• On-Line Backup & Restore
• Node monitoring
• Auto-recovery extended to SQL + mgmt nodes
• Cluster-wide configuration consistency
• Persistent configurations
• HA Agents
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 55
Reference Architecture - Summary
Designed as a springboard to
innovating on the web
Based on insight from most
successful web properties
Best practices & repeatable
technologies for Scale & HA
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 56
Next Steps MySQL Web Reference Architectures Whitepaper
http://www.mysql.com/why-mysql/white-papers/mysql_wp_high-availability_webrefarchs.php
MySQL 5.6: Developer and DBA Guide
http://www.mysql.com/why-mysql/white-papers/whats-new-mysql-5-6/
Engage MySQL Consulting
<Insert Picture Here>
MySQL Web Reference ArchitecturesBuilding Massively Scalable Web Infrastructure