Arquiteturas de Referência WebConjunto de boas práticas
Airton Lastoriset-2014
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
s
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 4
Agenda
Requisitos Web, níveis de escala
Arquiteturas de Referência– Escalas & Topologias
– Tecnologias envolvidas na Infraestrutura
– Boas práticas
Um pouco sobre Hardware
Considerações Operacionais
Conclusão
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 5
Desdobramentos na Infraestrutura
Ágil, aberta & adaptávelSimples & replicávelBaixa latênciaEscalável e DiponívelSegurança extremaBaixo TCO
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 6 Fonte: http://db-engines.com/en/ranking_trend (set/14)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 7
MySQL é estratégico para Oracle
Soluções Completas
#1 em todos os níveis da pilha
Cloud e On Premise
MySQL: Web, Mobile & Embedded
Investimentos na Engenharia do MySQL
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 8
Alguns clientes MySQL
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 10
Compromisso Oracle com MySQL
https://blogs.oracle.com/MySQL/entry/mysql_connect_keynotes_and_news
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 11
@MySQLBR
meetup.com/MySQL-BR
facebook.com/MySQLBR
MySQLBR
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 12
Arquiteturas de Referência
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 13
Referências de EscalaSocial 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. | 14
Pequena EscalaSocial 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. | 15
Pequena Escala
Um único servidor para:– Perfis de usuário e sessões
– eCommerce
– Gerenciamento de conteúdo
Replicação MySQL– Analítico e Backups
Se o tráfego aumentar, o gerenciamento de sessões pode ser direcionado para outro servidor.
Escalabilidade limitada.Se já é previsto aumento de demanda, inicie com Arquitetura para Média escala.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 16
Replicação MySQL Duplique databases de um “master” para um “slave”
– Cópias redundantes do dados, peça fundamental na Alta Dispinibilidade
– Escale horizontalmente distribuindo queries nos slaves
Master
Slaves
Web / App Servers
Writes & Reads Reads
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 17
Boas Práticas
Use o Storage Engine correto– InnoDB atende a maior parte dos cenários, default a partir do MySQL 5.5
– Atualize para MySQL 5.6
Hot Backup e Recovery rápido Monitoramento pró-ativo Mantenha a qualidade do tempo de reposta das queries Auditoria Reforçe políticas de segurança com autenticação externa Thread Pool para escalabilidade vertical
Arquiteturas de Pequena Escala
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 18
2008
até 4 CPUMySQL 5.0
MySQL AB
até 16 CPUMySQL 5.1
Sun
até 32 CPUMySQL 5.5
Oracle
até 48 CPUMySQL 5.6
Evolução da escalabilidade do MySQL
2009 2010 2013
Use InnoDB para usufruir melhor de hardwares modernos.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 19
Enterprise Management Services and Utilities
Backup & RecoveryMonitor
WorkbenchUtilities
Connection Pool, SQL Interface, Parser, Optimizer, Caches
Clients & ConnectorsNative C API, JDBC, ODBC, .Net, PHP, Ruby, Python, VB, Perl mysqld
Clients and Apps
Arquitetura MySQL Server
Storage EnginesInnoDB, MyISAM, Memory, Archive, Cluster (NDB API), etc…
Filesystems, Files & LogsData, Index, Logs…
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 21
MySQL 5.5.28
MySQL 5.6.7
+234% Ganhos de Performance
32 64 128 256 5120
4,000
8,000
12,000
16,000
MySQL 5.6 vs. 5.5 - Leituras (Linux)
Conexões
Tra
ns
aç
õe
s p
or
Se
gu
nd
o
Oracle Linux 6Intel(R) Xeon(R) E7540 x86_64MySQL leveraging:- 48 of 96 available CPU threads- 2 GHz, 512GB RAM
Performance MySQL 5.6: InnoDBSysBench Benchmarks
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 22
MySQL 5.5.28
MySQL 5.6.7
+151% Ganhos de Performance
32 64 128 256 5120
2,000
4,000
6,000
8,000
10,000
12,000
MySQL 5.6 vs. 5.5 – Escritas+Leituras (Linux)
Conexões
Tra
ns
aç
õe
s p
or
Se
gu
nd
o
Oracle Linux 6Intel(R) Xeon(R) E7540 x86_64MySQL leveraging:- 48 of 96 available CPU threads- 2 GHz, 512GB RAM
Performance MySQL 5.6: InnoDBSysBench Benchmarks
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 23
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 24
PerformanceSecurity
Availability
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 25
MySQL Enterprise Backup Backup online para InnoDB, tamanho ilimitado Backups automatizados: completos, incrementais, parciais Compressão, Criptografia Metadados de status, progresso e histórico Compatível SBT, Oracle Secure Backup Suporte Cloud (Amazon S3) Point in Time Recovery, Parcial ou Completo Multi-Plataforma: Windows, Linux, Unix
MEB Backup
Files
MySQL Database
Files
mysqlbackup
Backup e Recovery mais rápidos e online.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 27
2. Usuário conecta-se e executa queries
MySQL Enterprise Audit
1. DBA habilita no Server1Server1
3. Conexões e queries dos usuários aparecem no log
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 29
Authenticate
CREATE USER win_joe IDENTIFIED WITH authentication_windows AS ‘joe';
LDAP/ADPAM / Windows Auth
Usuário/senha definidos no diretório
Privilégios definidos no MySQL e mapeados para usuários/grupos do diretório
MySQL Enterprise SecurityExternal Authentication Plug-Ins
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 31
60x Melhor Escalabilidade comThread Pool
MySQL 5.6.11Oracle Linux 6.3, Unbreakable Kernel 2.6.324 sockets, 24 cores, 48 ThreadsIntel(R) Xeon(R) E7540 2GHz CPUs512GB DDR3 RAM
Thread Pool habilitado/desabilitado
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 32
18x Melhor Escalabilidade com Thread Pool
Thread Pool habilitado/desabilitado
MySQL 5.6.11Oracle Linux 6.3, Unbreakable Kernel 2.6.324 sockets, 24 cores, 48 ThreadsIntel(R) Xeon(R) E7540 2GHz CPUs512GB DDR3 RAM
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 33
MySQL Enterprise Encryption
Standards Based Cryptography
MySQL encryption libraries – Symmetric encryption AES256
– Public-key / asymmetric cryptography
Key management– Generate public and private keys
– Key exchange methods: RSA, DSA, DH
Sign and verify data– Cryptographic hashing for digital signing, verification, & validation
33
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 34
Média EscalaSocial 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. | 35
Média Escala
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 36
Boas Práticas
Proporção de 10 servidores de aplicação para cada MySQL Server– Mais para aplicações PHP, menos para Java
– Adicione mais slaves quando a camada de aplicação escalar
Camada de Cache para gerenciamento de sessões & componentes do Gerenciador de Conteúdo
– Memcached ou Redis são comuns
– Leituras atendidas pelo cache, aliviando a carga no MySQL
– API NoSQL Memcached do MySQL 5.6 ou MySQL Cluster podem implementar compressão e/ou persistência nas camadas de cache
Arquiteturas de Média Escala
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 37
Boas Práticas – Gerenciador de ContéudoArquiteturas de Média Escala
XOR
Cada slave atende por volta de 5.000 usuários simultâneos
Cada master atende por volta de 20 slaves – Mais slaves podem ser necessários em ambientes maiores
Replicação do MySQL para alta disponibilidade e escalabilidade horizontal
Meta dados dos arquivos gerenciados pelo MySQL Distributed File System / CDN / Cloud (e. S3) para
armazenamento físico dos arquivos– SAN de alta qualidade, com redundancia para HA, ou
– Hardware commodity com software especializado (ex. MogileFS)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 38
Boas Práticas – Sessões e e-Commerce
Gerenciamento de Sessões & e-Commerce– Dados das Sessões mantidos por aproximadamente 1 hora em uma partição
dedicada; partições antiga são excluídas
– API NoSQL Memcached do MySQL 5.6 ou MySQL Cluster ser usadas
– Alta diponibilidade em e-Commerce: Semi-Synchronous Replication or clusterização via DRBD ou shared storage
– Se o tráfego aumentar, mova o Gerenciamento de Sessões para o MySQL Cluster Persistência dos dado de sessão em tempo real, dados in-memory reduzem a necessidade
caching
99,999% de disponibilidade (multi-master), elimina necessidade de DRBD ou shared storage
Bases separadas para Dados Analíticos (ex. Data Mart, Relatórios)
Arquiteturas de Média Escala
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 39
Alta-Disponibilidade: soluções certificadas
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 41
Mais performance com multi-threaded slaves, row image minimal, binlog group commit
Maior robustez e consistência com event checksums, crash safe slaves
Mais flexibilidade e disponibilidade com GTID, self-healing, auto-failover, Replication Utilities e MySQL Enterprise Monitor
Master
#
Slave
#
Replicação melhorada no MySQL 5.6
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 42
Permite self-healing
Failover & recovery automatizado- mysqlfailover (Utilitário)
Switchover & administração- mysqlrpladmin (Utilitário)
Alta disponibilidade com MySQL core- Elimina necessidade de soluções de
terceiros; Fácil de estender
HA UtilitiesMonitoramento
MasterFalhou
Slaves
Slave Promovido para Master
Disponibilidade com Replicação no MySQL 5.6Replication HA Utilities (Python)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 43
• Soluções homologadas e suportadas pela Oracle MySQL– Oracle Clusterware– Oracle VM Template– Windows Failover Clustering– Oracle Solaris Cluster
VIP
Clie
nts
Clusterização baseada em Shared-Storage
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 44
http://www.oracle.com/technetwork/database/database-technologies/clusterware/downloads/index.html
MySQL Grid Control Agent for ClusterwareOracle Clusterware
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 45
Oracle VM Servers
Oracle VM Server Pool
ocfs2
Oracle VM Manager
SAN / iSCSI
Secure Live Migration (SSL)
Oracle VM
Automatic Fault Detection & Recovery
Oracle VM
mysql.com/why-mysql/white-papers/mysql_wp_oracle-vm-template-for-mee.php
• Oracle Linux
• Oracle VM
• Oracle VM Template for MySQL EE
• Oracle Cluster File System 2 (OCFS2)
• MySQL Database 5.5 Enterprise Edition
Pré-instalado & Configurado
Integrado & Testado
Suporte de um único fornecedor
Oracle VM Template for MySQL Enterprise
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 46
oracle.com/technetwork/server-storage/solaris-cluster/overview/index.html
• Heartbeat e monitoramento baseado no Kernel
• SPARC e x86. Solaris Virtualization-aware
• Agente MySQL incluíd o no Oracle Solaris Cluster
Oracle Solaris Clustering
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 47
Opção nativa do Windows certificada para MySQL Enterprise
Para Falhas ou Manutenção Planejada
Cluster gerenciado pela interface snap-in MS Failover Cluster Management*, não requer scripts customizados
Perda de serviço = alguns segundos + tempo de recovery do InnoDB:
• Aplicação vê temporariamente uma perda de conexão e reconecta no mesmo IP
• Slave na Replicação recupera-se automaticamente
Quorum (3o voto), dados (InnoDB + schema) & binários (opcional) em armazenamento compartilhado
• teste com iSCSI & FCAL
*suporte técnico do componente MS Failover Cluster Management deve ser contratado da Microsoft
Windows Server Failover Clustering
mysql.com/why-mysql/white-papers/mysql_wp_windows_failover_clustering.php
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 48
mysql.com/why-mysql/white-papers/mysql_wp_drbd.php
• Certificado e completamente suportado pela Oracle
• DRBD integrado ao Oracle Linux Unbreakable Enterprise Kernel R2
• Pacemaker e Corosync para clustering & failover
• Updates na pilha via ULN channel
• Baseado em storage distribuído, não requer SAN
• Replicação síncrona elimina o risco de perda de dados
• Maduro & já utilizado em muitos casos
Oracle Linux + DRBD Stack
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 49
MySQL Cluster
•Escalabilidade linear de Escritas e Leituras
•Elasticidade, crescimento incremental, distrib. simétrica
Escalabilidade
•99,999% de disponibilidade, 5min / ano
•Self-healing, failover menor que 1s, geo-replicação
Alta Disponibilidade
•Performance em tempo real, in-memory e em disco
•Latência baixa e preditiva, acessos paralelos
Alta Performance
•Modelo relacional ACID, SQL e Foreign Keys
•APIs NoSQL (C++, Java, Memcached, Node.js)
Flexibilidade
•Open Source, suporte e ferramentas comerciais opcionais
•Hardware commodity
Baixo TCO
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 50
Cluster Data Nodes
NDB NDB
Connection Pool, SQL Interface, Parser, Optimizer, CachesEnterprise Management
Services and Utilities
Backup & RecoveryMonitor
WorkbenchUtilities
Clients & ConnectorsNative C API, JDBC, ODBC, .Net, PHP, Ruby, Python, VB, Perl
Arquitetura MySQL Cluster
Storage EnginesInnoDB, MyISAM, Memory, Archive, Cluster (NDB API), etc…
Filesystems, Files & LogsData, Index, Logs…
mysqld
Clients and Apps
ndbd
mgm_ndbdManagement
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 51
API Nodes
Arquitetura MySQL Cluster
Data Nodes
ndbd ndbd
Managementmgm_ndbd
Clients
Application Layer
Data Layer
ndbd ndbd
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 53
Soluções de HA homologadas pela OracleMySQL
ReplicationMySQL Fabric
Oracle VM Template
Solaris Cluster
Windows Cluster
DRBDMySQL Cluster
Clustering ModeMaster + Slaves
Master + Slaves
Active/Passive
Active/Passive
Active/Passive
Active/Passive
Multi-Master
App Auto-Failover ✖ ✔ ✔ ✔ ✔ ✔ ✔
Data Layer Auto-Failover ✖ ✔ ✔ ✔ ✔ ✔ ✔
Zero Data Loss MySQL 5.7 ✔ ✔ ✔ ✔ ✔ ✔
Failover Time N/A Secs Secs + Secs + Secs + Secs + < 1 Sec
Scale-out Reads ✔ ✖ ✖ ✖ ✖ ✔
Cross-shard operations N/A ✖ N/A N/A N/A N/A ✔
Transparent routing ✖ For HA ✔ ✔ ✔ ✔ ✔
Shared Nothing ✔ ✔ ✖ ✖ ✖ ✔ ✔
Storage Engine InnoDB InnoDB InnoDB InnoDB InnoDB InnoDB NDB
Single Vendor Support ✔ ✔ ✔ ✔ ✖ ✔ ✔
Platform Support All All Linux Solaris Windows Linux All
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 54
Grande EscalaSocial 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. | 55
Grande Escala
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 56
Caso de uso: Loja On-Line
UsuáriosNavegação
Recomendações
Web Logs:Páginas Visitadas,Comentários, Posts
Perfil, Histórico de
Compras
Recomendações
Interações em Mídias Sociais, Preferências, Marcas com “Curtir”
Conversas Telefônicas,mensagens
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 57
sistema de publicidade online que identifica o visitante e exibe conteúdo direcionado ao seu perfil
2 TB de web logs são capturados, com 22 bilhões de linhas por mês processadas pelo MySQL
Atualmente, considerando apenas uma instância MySQL, há 8 TB de dados armazenados com 5GB de crescimento por dia
Caso de Sucesso
Big Data
“O MySQL é uma parte essencial da nossa estratégia de Big Data. A integração com Hadoop permite-nos melhorar e crescer o nosso negócio de publicidade digital com rapidez e agilidade.”
Josafá SantosIT Manager, boo-box
mysql.com/why-mysql/case-studies/1billion-advertisements-mysql-hadoop.html
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 58
BI Solutions
ACQUIRE
ORGANIZEANALYZE
DECIDE
Hadoop Applier
Big Data Lifecycle com MySQL+Hadoop
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 59
Novo: MySQL Hadoop Applier
Integração em tempo real do MySQL para Hadoop
Cada tabela mapeada para um diretório Hive data warehouse
Possibilita usufruir de ferramentas de análise do eco-sistema Hadoop
Construído sobre MySQL Binlog API e libhdfs library
Artigos dev.mysql.com Download labs.mysql.com
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 60
Mais sobre como MySQL e Big Data
Whitepaper:MySQL and Hadoop – Big Data IntegrationDecember 2012mysql.com/why-mysql/white-papers/mysql-and-hadoop-guide-to-big-data-integration
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 61
Acesso chave-valor ao InnoDBVia Memcached API
Usa clients Memcached existentes
Sem SQL parsing, ultra-rápido
Acesso SQL e NotOnlySQLOperações chave-valor mas também queries SQL, JOINs, FKs, etc.
Memcached com Persistência no InnoDB
Método transparente para persistir os dados em memória volátil
Memcached plug-in no mysqld , mapeado à API nativa do InnoDB
Shared process para baixa latência
SQL (MySQL Client)
InnoDB Storage Engine
MySQL Server Memcached plugin
Application/Client
NoSQL (Memcached Prot.)
mysqld
http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached.html
Flexibilidade MySQL 5.6: InnoDBNoSQL com Memcached
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 62
MySQL 5.7: InnoDB MemcachedContribuição do Facebook
Intel(R) Xeon(R) CPU X7560 x86_648 sockets x 6 cores-HT (96 CPU threads) 2000Mhz, 256G RAMOracle Linux 6.2
6x mais rápido que o MySQL 5.6
1,150,000 QPS
8 16 32 64 128 256 512 10240
200000
400000
600000
800000
1000000
1200000
1400000
5.7.3
5.6
Concurrent User Sessions
Qu
erie
s p
er S
eco
nd
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 63
Escala Extra Grande (Redes Sociais)Social 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. | 64
Extra Large: Social Network
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 65
Boas Práticas
Introdução de técnicas de Sharding– Normalmente implementado na camada de aplicação para escalar um volume muito alto de
escritas (ex. Youtube Vitess, Twitter Gizzard, Tumblr JetPants etc)
– Dados divididos em pequenos conjuntos, distribuído em servidores de baixo custo
– Distribuição baseada em Hash de uma única coluna (ex. User ID)
– Particionamento Funcional também é uma opção
Use com moderação, certifique-se de tentar as recomendações anteriores– Replicação convencional e escalabilidade vertical serão suficientes em muitos casos, com
menor complexidade
– Sharding é realmente necessário em uma pequena porcentagem de casos
– Muitos serviços Web & Mobile ainda possuem mais leituras que escritas
– MySQL Cluster implementa Auto-Sharding com JOINs entre shards
Arquiteturas de Escala Extra Grande
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 66
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. | 67
MySQL Fabric 1.4 RC (MySQL Utilities 1.4.2)
Alta disponibilidade:– Monitoramento do Server com failover
automático e transparente para aplicação
Conectores devem ser “Fabric-aware”:– Java, PHP, Python
Sem Proxy, sem latencia extra e SPoF Escalabilidade de escrita com sharding:
– Aplicação define a shard key (Range ou Hash)
– Ferramentas para re-sharding– Tabelas globais & global updates
Alta-disponibilidade + escalabilidade de escrita com sharding
MySQL Fabric
Connector
Application
Read-slaves
mappings
SQL
Master group
Read-slaves
Master group
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 68
Hardware
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 69
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. | 70
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. | 71
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. | 72
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 SelectionDisk Subsystem for Checkpointing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 73
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 SelectionDisk Data Storage
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 74
Considere MySQL Enterprise para implementar boas práticas operacionais
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 75
MySQL Enterprise EditionSubscrição com renovação anual: ferramentas + serviços
Plug-ins
Suporte
Backup
Monitor & Workbench
EscalabilidadeSegurança
Auditoria
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 76
MySQL Cluster Carrier-Grade EditionSubscrição com renovação anual: ferramentas + serviços
ClusterPlug-ins
Suporte
Backup
Monitor & Workbench
ClusterManager
Gerenciamento Consolidado
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 77
Conclusão
Foco no mercado e soluções web
Recomendações baseadas em casos
de muito sucesso da web
Considerar os desafios operacionais
de escalabilidade, performance e alta-
disponibilidade
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 78
Saiba Mais
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/
MySQL Enterprise com Suporte [email protected]
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 79
MySQL for Beginners Ed 3
MySQL for Database Administrators Ed 2
MySQL Performance Tuning
MySQL High Availability
MySQL Cluster
MySQL DBA
Introduction to MySQL 5.5
MySQL Developers Techniques
MySQL for Beginners Ed 3
MySQL and PHP Developing Dynamic
Web Applications
MySQL for Developers Ed 2
MySQL Advanced Stored Procedures
MySQLDeveloper
education.oracle.com/mysql
Opcional
Necessário
Treinamentos e certificações
Oracle Certified Associate, MySQL 5
Oracle Certified Professional, MySQL 5.6
DBA
Oracle Certified Expert, MySQL Cluster DBA
Certificações
Oracle Certified Professional, MySQL 5
Developer
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. | 80
@MySQLBR
meetup.com/MySQL-BR
facebook.com/MySQLBR
Obrigado!
Arquiteturas de Referência WebConjunto de boas práticas
Perguntas?