SlideShare a Scribd company logo
1 of 49
Download to read offline
“
Perché dovrei avere un
database su Kubernetes?
“
Perché dovrei usare Postgres
come database?
“
Perché dovrei fare un
benchmark del database prima
di andare in produzione?
Benchmarking
Cloud Native
PostgreSQL
Francesco Canovai
1 Luglio 2021
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Francesco Canovai
• PostgreSQL
• Infrastruttura
• Automazione
• Testing
• Kubernetes
5
Twitter: @fcanovai / @EDBPostgres
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Argomenti
• I “perché”
• Com’è iniziato
• Storage
• Database
• cnp-bench
• Risultati
• Conclusioni
Intro
I “Perché”
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Perché un database su Kubernetes
Utilizzare al meglio un’infrastruttura a microservizi
8
● Un microservizio dovrebbe essere il proprietario dei suoi dati
○ I dati devono essere organizzati in un singolo data store o database
○ Solo il servizio deve avere accesso ai dati
○ Gestione dello schema inclusa
● Riduce il Carico cognitivo del Team
○ “Software that fits in your head” (Dan North)
● Definire chiare interfacce di comunicazione tra microservizi
● In Kubernetes, le applicazioni e i database coesistono:
○ Tutto è un workload (incluso il database)
○ Container e microservizi sono parte della definizione di Cloud Native
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Esempio di microservizi
9
Applicazioni web con backend PostgreSQL
Rest API
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
PostgreSQL popularity
Source: DB-Engines.com, 2021
Source: Stack Overflow Developer Survey, 2020
Perché PostgreSQL?
10
2017
2018
2020
Most loved database
Chi lo prova lo ama
Most popular database
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Feature
11
Versione ridotta
● Replica streaming nativa, logica e fisica, sincrona ed asincrona
● Continuous backup e point in time recovery
● Partizionamento dichiarativo
● Supporto JSON
● Estensioni (e.g. PostGIS)
● Query parallele
● INSERT .. ON CONFLICT DO UPDATE
● Supporto TLS e autenticazione con certificati
● SQL Standard (2016)
● DDL transazionali
● Ricerca full text nativa
● Tablespace
● ...
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
PostgreSQL: architettura di replica
12
Primario e repliche tramite replica streaming fisica nativa
● PostgreSQL supporta in modo nativo l’architettura primary/standby
○ Evolutione della Crash Recovery e della Point-In-Time Recovery
○ Introdotta in PostgreSQL 8.2 con WAL shipping e Warm Standby
○ Migliorata in PostgreSQL 9.0 con WAL streaming e Hot Standby (replica sola lettura)
● Ulteriori miglioramenti:
○ Replica sincrona
○ Replica in cascata
○ Replica logica
● Robusta e affidabile, con ottimi risultati in termini di RPO e RTO
2021 Copyright © EnterpriseDB Corporation All Rights Reserved 13
Due approcci a PostgreSQL su Kubernetes
Operatore (con replica PostgreSQL)
Container (con replica del file system)
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Stato richiesto Stato attuale
RW RW
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Cloud Native PostgreSQL by EDB
15
Il migliore database open source sul migliore orchestratore di container open source
● Operatore proprietario, con una licenza di prova implicita di 30 giorni
● Operandi:
○ PostgreSQL
○ EDB Postgres Advanced Server
● Documentazione disponibile
○ docs.enterprisedb.io
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Perché fare benchmark su PostgreSQL
16
Metodo scientifico
● Decisioni basate su dati e misurazioni ripetibili
○ “Lo sanno tutti” vs. “Perché le TPS osservate non sono sufficienti”
● Obiettivi:
○ Capacity planning e ottimizzazione dei costi
○ Prestazioni predicibili
● Prestazioni
○ Possono variare per molteplici fattori (hardware, software, network!)
○ Il database è pesantemente influenzato dallo storage (bottleneck)
● Prima di andare in produzione
Parte 1
Come è iniziato
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Un nuovo prodotto in 2ndQuadrant
18
L’esplorazione di Kubernetes inizia nel Q3/2019
● Contesto: esperienza pluriennale su DevOps/Lean/Agile
● Portare PostgreSQL su Kubernetes
○ Cosa manca dentro PostgreSQL per un esperto Kubernetes?
○ Cosa manca in Kubernetes per un esperto PostgreSQL?
○ Esplorazione con approccio fail-fast
● Obiettivo: arrivare in Kubernetes allo stesso livello che abbiamo su PostgreSQL
○ Prima compagnia PostgreSQL a diventare Kubernetes Certified Service Provider
● Per le nostre esperienza, le prestazioni dello storage erano la priorità principale
○ Possiamo fare funzionare PostgreSQL in un Kubernetes su bare-metal?
2021 Copyright © EnterpriseDB Corporation All Rights Reserved 19
Parte 2
Storage
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Cosa si aspetta un database dallo storage?
21
In bare metal, VM e container
● Disponibilità
● Scalabilità
● Prestazioni
● Consistenza
● Durabilità
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Storage e architetture
22
● Antipattern K8s
● Accesso diretto allo storage del SO
○ Sul nodo worker
● Richieste degli utenti PostgreSQL
○ Architettura shared nothing
○ Prestazioni
○ Predicibilità
○ HA tramite replica Postgres
Locale
Network
• Pattern K8s
• Numerose soluzioni disponibili
• HA tramite replica dello storage
• Storage condiviso
• Altri workload
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
PostgreSQL e lo storage (versione semplificata)
23
Dove lo storage diventa critico per PostgreSQL
● Write Ahead Log (WAL), in passato xlog
○ Scritture sequenziali e fsync
● Scrittura degli shared buffers
○ Fatta dal checkpoint, dal bgwriter, o dal backend
○ Scritture random
● Letture di pagine
○ Letture random
● Table scan
○ Letture sequenziali
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Cosa misurare
24
Metriche per la valutazione di uno storage
● Throughput:
○ Sequential read
○ Sequential write
○ Random read
○ Random write
● IOPS:
○ Limiti sul cloud
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Come misurare
25
● Il tool che abbiamo scelto per le misure
○ In passato abbiamo utilizzato bonnie++
● Simula numerosi tipi di I/O
● Configurable
● Multi-piattaforma
○ Utilizzabile anche su Kubernetes
● Open Source
○ GNU GPL 2
○ https://fio.readthedocs.io/
fio: Flexible I/O
“
Se lo storage è lento
il database sarà lento
Parte 3
Database
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Workload PostgreSQL
28
Tipi di carico di lavoro
● In-Memory
○ Il database entra interamente in RAM
○ Limitato da velocità di CPU e RAM
● OnLine Transactional Processing (OLTP)
○ Molte piccole transazioni concorrenti
○ Mix di inserimenti, letture e aggiornamenti
● OnLine Analytical Processing (OLAP)
○ Poche query complesse, principalmente in lettura, su dati storici
○ Usato per reportistica e business intelligence
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Cosa misurare
29
Quali metriche usare per valutare le prestazioni del database?
● Ci siamo concentrati su:
○ Carico di lavoro OLTP
○ Dimensione del database superiore alla RAM
■ Questo ci costringe a lavorare sul disco
● Metrica scelta:
○ Transazioni al secondo (TPS)
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Come misurare
30
pgbench
● Lo strumento che abbiamo scelto per il benchmark del database
● Parte del core di PostgreSQL
● Simula un carico di lavoro TPC-B like (OLTP)
● Configurabile
○ scale factor, numero di client e thread, durata, …
● Open Source, TPL
● Supporto per query custom
○ Niente batte l’applicazione reale
Parte 4
cnp-bench
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
cnp-bench
32
● Una raccolta di Helm chart
○ Facili da eseguire
○ Facili da personalizzare
○ Facili da riprodurre
● Esecuzione di benchmark per cluster Cloud Native PostgreSQL (CNP)
○ Utilizza fio e pgbench
○ Misurazione di IOPS e TPS
● github.com/EnterpriseDB/cnp-bench
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Fio benchmark
33
● Creazione di un PVC
○ Scegliendo la storage class e la dimensione
● Crea una ConfigMap per il job fio
○ Specifica il tipo di workload da eseguire sul PVC
● Fio è eseguito come deployment
○ Effettua il benchmark
○ Serve i risultati
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
values.yaml
34
pvcStorageClassName: default
pvcSize: 2Gi
nodeSelector: {}
jobRW: read
jobBs: 8k
jobRuntime: 60
jobTimeBased: 1
jobSize: 1G
jobIodepth: 32
jobDirect: 1
jobIoengine: libaio
jobEndFsync: 1
jobLogAvgMsec: 1000
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Risultati
35
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
pgbench
36
● Avvia un cluster Cloud Native PostgreSQL
○ Configurabile
○ Impostazioni di PostgreSQL diverse possono cambiare il risultato
● Esegue un job con pgbench
● I log di pgbench contengono i risultati
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
values.yaml
37
cnpInstances: 1
cnpStorageClass: default
cnpSize: 1Gi
cnpImage: quay.io/enterprisedb/postgresql:13.3
cnpNodeSelector:
workload: postgresql
cnpPostgreSQLParameters:
shared_buffers: '512MB'
maintenance_work_mem: '128MB'
pgbenchNodeSelector:
workload: pgbench
pgbenchScaleFactor: 1
pgbenchTime: 60
pgbenchClients: 1
pgbenchJobs: 1
pgbenchWarmTime: 0
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Risultati
38
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
duration: 60 s
number of transactions actually processed: 23114
latency average = 2.596 ms
tps = 385.225531 (including connections establishing)
tps = 385.271092 (excluding connections establishing)
Parte 5
cnp-bench su AKS
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
AKS
40
● Abbiamo eseguito dei test su AKS, con diverse combinazioni di VM dischi
● Le VM non sono definite solo da CPU e RAM
○ Diverse VM hanno limiti diversi per IOPS, larghezza di banda per I/O e rete
● Anche i dischi hanno i loro limiti di IOPS e banda
○ Alcuni dischi permettono di eccedere i limiti per breve tempo (burst)
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
AKS
41
Network storage
● P10
● P30
● P80
Standard_E8d_v4
● vCPU: 8
● RAM: 64GB
● Network bandwidth: 4000 Mb/s
Disk Size (GiB) BW (MiB/s) IOPS Burst
P10 100 100 500 Yes
P30 1000 200 5000 No
P80 20000 900 20000 No
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Benchmark fio: risultati
42
3600s - 8kb block size
Disk
Max BW
(MiB/s)
Max
IOPS
Seq Read Seq Write Rand Read Rand Write
MB/s IOPS MB/s IOPS MB/s IOPS MB/s IOPS
P10 100 500 483 58994 16.4 2003 452 55137 15.5 1960
P30 200 5000 85.3 10415 41.6 5082 42.7 5217 37.5 4575
P80 900 20000 81.3 9930 89.1 10881 92.6 11306 68.2 9655
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Il burst
43
Scritture sequenziali sul P10
Max BW
(MiB/s)
Max
IOPS
Seq Write
MB/s IOPS
100 500 16.4 2003
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
La cache di lettura
44
Disk
BW
(MiB/s)
IOPS
Seq Read Seq Write Rand Read Rand Write
MB/s IOPS MB/s IOPS MB/s IOPS MB/s IOPS
P10 100 500 483 58994 16.4 2003 452 55137 15.5 1960
P10NC 100 500 16.3 1986 16.4 2003 16.3 1985 15.5 1952
P30 200 5000 85.3 10415 41.6 5082 42.7 5217 37.5 4575
P30NC 200 5000 41.7 5088 41.6 5082 41.7 5087 37.5 4580
P80 900 20000 81.3 9930 89.1 10881 92.6 11306 68.2 9655
P80NC 900 20000 88.3 10778 88.2 10795 90.7 11,074 68.3 9621
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Durata: 1h
Dimensioni diverse del DB per dischi diversi
Configurazioni di PostgreSQL (comuni):
● shared_buffers: '16GB'
○ 64GB di RAM
● max_wal_size: '15GB'
● checkpoint_timeout: '900s'
● checkpoint_completion_target: '0.9'
● maintenance_work_mem: '2GB'
Pgbench: risultati
45
Disk DB size (GB) TPS
P10 71 1,499
P30 731 1,274
P80 1,490 1,051
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Work in progress: storage locale
46
Standard_L8s_v2
CPU: 8
RAM: 64
Throughput:
Max Read BW: 2000 MB/s
Max Read IOPS: 400000
Disks: 1x1.92 TB NVME
Seq Read Seq Write Rand Read Rand Write DB size
(GB)
TPS
MB/s IOPS MB/s IOPS MB/s IOPS MB/s IOPS
1,142 139,370 696 84,996 1,070 130,587 262 32,010 732 2,082
Conclusioni
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Riepilogo degli argomenti
48
PostgreSQL su Kubernetes? Si può fare!
● Un metodo per effettuare benchmark di PostgreSQL su Kubernetes
● Degli strumenti open source per il benchmark
● Perché è importante fare benchmark dello storage e del database
● Usare cnp-bench per il benchmark di Cloud Native PostgreSQL:
○ github.com/EnterpriseDB/cnp-bench
2021 Copyright © EnterpriseDB Corporation All Rights Reserved
Stiamo assumendo!
• enterprisedb.com/careers
• Numerose posizioni
• Da remoto, in tutto il mondo
• Nel nostro team:
• GoLang Developer, Kubernetes
• Automation engineer, DevOps/Kubernetes

More Related Content

What's hot

Power BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-servicePower BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-serviceMarco Pozzan
 
SQL Server Modern Query Processing
SQL Server Modern Query ProcessingSQL Server Modern Query Processing
SQL Server Modern Query ProcessingGianluca Hotz
 
Infinispan codemotion - Codemotion Rome 2015
Infinispan codemotion - Codemotion Rome 2015Infinispan codemotion - Codemotion Rome 2015
Infinispan codemotion - Codemotion Rome 2015Codemotion
 
Operational Data Store vs Data Lake
Operational Data Store vs Data LakeOperational Data Store vs Data Lake
Operational Data Store vs Data LakeMongoDB
 
Hadoop
HadoopHadoop
HadoopReply
 
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...MongoDB
 
Big data - stack tecnologico
Big data -  stack tecnologicoBig data -  stack tecnologico
Big data - stack tecnologicoConsulthinkspa
 
Cyber Security in Multi Cloud Architecture - Luca Di Bari - Codemotion Rome 2017
Cyber Security in Multi Cloud Architecture - Luca Di Bari - Codemotion Rome 2017Cyber Security in Multi Cloud Architecture - Luca Di Bari - Codemotion Rome 2017
Cyber Security in Multi Cloud Architecture - Luca Di Bari - Codemotion Rome 2017Codemotion
 
2014.11.14 Implementare e mantenere un progetto Azure SQL Database
2014.11.14 Implementare e mantenere un progetto Azure SQL Database2014.11.14 Implementare e mantenere un progetto Azure SQL Database
2014.11.14 Implementare e mantenere un progetto Azure SQL DatabaseEmanuele Zanchettin
 
2014.11.14 Implementare e mantenere un progetto Azure SQL Database
2014.11.14 Implementare e mantenere un progetto Azure SQL Database2014.11.14 Implementare e mantenere un progetto Azure SQL Database
2014.11.14 Implementare e mantenere un progetto Azure SQL DatabaseEmanuele Zanchettin
 
Azure Synapse: data lake & modern data warehouse dalla A alla Z
Azure Synapse: data lake &  modern data warehouse dalla A alla ZAzure Synapse: data lake &  modern data warehouse dalla A alla Z
Azure Synapse: data lake & modern data warehouse dalla A alla ZRoberto Messora
 
Cloud storage in azienda: perche` Riak ci e` piaciuto
Cloud storage in azienda: perche` Riak ci e` piaciutoCloud storage in azienda: perche` Riak ci e` piaciuto
Cloud storage in azienda: perche` Riak ci e` piaciutoBioDec
 
Webinar: Come semplificare l'utilizzo del database con MongoDB Atlas
Webinar: Come semplificare l'utilizzo del database con MongoDB AtlasWebinar: Come semplificare l'utilizzo del database con MongoDB Atlas
Webinar: Come semplificare l'utilizzo del database con MongoDB AtlasMongoDB
 
Apache Hadoop: Introduzione all’architettura ed approcci applicativi
Apache Hadoop: Introduzione all’architettura ed approcci applicativiApache Hadoop: Introduzione all’architettura ed approcci applicativi
Apache Hadoop: Introduzione all’architettura ed approcci applicativiDario Catalano
 
Presentazione Nuvola Vertica Light
Presentazione Nuvola Vertica LightPresentazione Nuvola Vertica Light
Presentazione Nuvola Vertica LightAlberto.F
 
SQL Saturday 2019 - Event Processing with Spark
SQL Saturday 2019 - Event Processing with SparkSQL Saturday 2019 - Event Processing with Spark
SQL Saturday 2019 - Event Processing with SparkAlessio Biasiutti
 
Hadoop - Introduzione all’architettura ed approcci applicativi
Hadoop - Introduzione all’architettura ed approcci applicativiHadoop - Introduzione all’architettura ed approcci applicativi
Hadoop - Introduzione all’architettura ed approcci applicativilostrettodigitale
 
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQL
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQLBack to Basics webinar 1 IT 17 - Introduzione ai NoSQL
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQLMongoDB
 

What's hot (20)

Power BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-servicePower BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-service
 
SQL Server Modern Query Processing
SQL Server Modern Query ProcessingSQL Server Modern Query Processing
SQL Server Modern Query Processing
 
Infinispan codemotion - Codemotion Rome 2015
Infinispan codemotion - Codemotion Rome 2015Infinispan codemotion - Codemotion Rome 2015
Infinispan codemotion - Codemotion Rome 2015
 
Operational Data Store vs Data Lake
Operational Data Store vs Data LakeOperational Data Store vs Data Lake
Operational Data Store vs Data Lake
 
Hadoop
HadoopHadoop
Hadoop
 
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
 
Big data - stack tecnologico
Big data -  stack tecnologicoBig data -  stack tecnologico
Big data - stack tecnologico
 
Presentazione bd2
Presentazione bd2Presentazione bd2
Presentazione bd2
 
Cyber Security in Multi Cloud Architecture - Luca Di Bari - Codemotion Rome 2017
Cyber Security in Multi Cloud Architecture - Luca Di Bari - Codemotion Rome 2017Cyber Security in Multi Cloud Architecture - Luca Di Bari - Codemotion Rome 2017
Cyber Security in Multi Cloud Architecture - Luca Di Bari - Codemotion Rome 2017
 
2014.11.14 Implementare e mantenere un progetto Azure SQL Database
2014.11.14 Implementare e mantenere un progetto Azure SQL Database2014.11.14 Implementare e mantenere un progetto Azure SQL Database
2014.11.14 Implementare e mantenere un progetto Azure SQL Database
 
2014.11.14 Implementare e mantenere un progetto Azure SQL Database
2014.11.14 Implementare e mantenere un progetto Azure SQL Database2014.11.14 Implementare e mantenere un progetto Azure SQL Database
2014.11.14 Implementare e mantenere un progetto Azure SQL Database
 
Azure Synapse: data lake & modern data warehouse dalla A alla Z
Azure Synapse: data lake &  modern data warehouse dalla A alla ZAzure Synapse: data lake &  modern data warehouse dalla A alla Z
Azure Synapse: data lake & modern data warehouse dalla A alla Z
 
Cloud storage in azienda: perche` Riak ci e` piaciuto
Cloud storage in azienda: perche` Riak ci e` piaciutoCloud storage in azienda: perche` Riak ci e` piaciuto
Cloud storage in azienda: perche` Riak ci e` piaciuto
 
Webinar: Come semplificare l'utilizzo del database con MongoDB Atlas
Webinar: Come semplificare l'utilizzo del database con MongoDB AtlasWebinar: Come semplificare l'utilizzo del database con MongoDB Atlas
Webinar: Come semplificare l'utilizzo del database con MongoDB Atlas
 
Apache Hadoop: Introduzione all’architettura ed approcci applicativi
Apache Hadoop: Introduzione all’architettura ed approcci applicativiApache Hadoop: Introduzione all’architettura ed approcci applicativi
Apache Hadoop: Introduzione all’architettura ed approcci applicativi
 
Presentazione Nuvola Vertica Light
Presentazione Nuvola Vertica LightPresentazione Nuvola Vertica Light
Presentazione Nuvola Vertica Light
 
SQL Saturday 2019 - Event Processing with Spark
SQL Saturday 2019 - Event Processing with SparkSQL Saturday 2019 - Event Processing with Spark
SQL Saturday 2019 - Event Processing with Spark
 
Hadoop - Introduzione all’architettura ed approcci applicativi
Hadoop - Introduzione all’architettura ed approcci applicativiHadoop - Introduzione all’architettura ed approcci applicativi
Hadoop - Introduzione all’architettura ed approcci applicativi
 
The Google File System
The Google File SystemThe Google File System
The Google File System
 
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQL
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQLBack to Basics webinar 1 IT 17 - Introduzione ai NoSQL
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQL
 

Similar to Benchmarking Cloud Native PostgreSQL

October 2009 - JBoss Cloud
October 2009 - JBoss CloudOctober 2009 - JBoss Cloud
October 2009 - JBoss CloudJBug Italy
 
JBoss Clouds - JBug Roma october 2009
JBoss Clouds -  JBug Roma october 2009JBoss Clouds -  JBug Roma october 2009
JBoss Clouds - JBug Roma october 2009Sanne Grinovero
 
Polyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDB
Polyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDBPolyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDB
Polyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDBSteve Maraspin
 
Marco Zani: Come dimensionare Magento per raggiungere i Key Performance Indic...
Marco Zani: Come dimensionare Magento per raggiungere i Key Performance Indic...Marco Zani: Come dimensionare Magento per raggiungere i Key Performance Indic...
Marco Zani: Come dimensionare Magento per raggiungere i Key Performance Indic...Meet Magento Italy
 
Regione Toscana - Introdution to R Software
Regione Toscana - Introdution to R SoftwareRegione Toscana - Introdution to R Software
Regione Toscana - Introdution to R SoftwareOmar Giorgetti
 
Valutazione sperimentale di un database relazionale in ambiente cloud
Valutazione sperimentale di un database relazionale in ambiente cloudValutazione sperimentale di un database relazionale in ambiente cloud
Valutazione sperimentale di un database relazionale in ambiente cloudMatteo Pani
 
Caso reale di migrazione da Windows a sistemi Open Source in azienda
Caso reale di migrazione da Windows a sistemi Open Source in aziendaCaso reale di migrazione da Windows a sistemi Open Source in azienda
Caso reale di migrazione da Windows a sistemi Open Source in aziendaClaudio Cardinali
 
MySQL Tech Tour 2015 - Progettare, installare e configurare MySQL Cluster
MySQL Tech Tour 2015 - Progettare, installare e configurare MySQL ClusterMySQL Tech Tour 2015 - Progettare, installare e configurare MySQL Cluster
MySQL Tech Tour 2015 - Progettare, installare e configurare MySQL ClusterPar-Tec S.p.A.
 
Glusterfs: un filesystem altamente versatile
Glusterfs: un filesystem altamente versatileGlusterfs: un filesystem altamente versatile
Glusterfs: un filesystem altamente versatileIvan Rossi
 
Glusterfs: un filesystem altamente versatile
Glusterfs: un filesystem altamente versatileGlusterfs: un filesystem altamente versatile
Glusterfs: un filesystem altamente versatileBioDec
 
iot Saturday 2019 - PoC iot in 1 ora
iot Saturday 2019 - PoC iot in 1 oraiot Saturday 2019 - PoC iot in 1 ora
iot Saturday 2019 - PoC iot in 1 oraAlessio Biasiutti
 
Web app slots and WebAPI versioning
Web app slots and WebAPI versioningWeb app slots and WebAPI versioning
Web app slots and WebAPI versioningNicolò Carandini
 
Web app slots and webapi versioning
Web app slots and webapi versioningWeb app slots and webapi versioning
Web app slots and webapi versioningNicolò Carandini
 
DbUp - A real case of database migration
DbUp - A real case of database migrationDbUp - A real case of database migration
DbUp - A real case of database migrationAndrea Cirioni
 
Azure PaaS databases
Azure PaaS databasesAzure PaaS databases
Azure PaaS databasesGianluca Hotz
 
RDX e Windows Backup: semplice ed economica protezione dei dati
RDX e Windows Backup: semplice ed economica protezione dei datiRDX e Windows Backup: semplice ed economica protezione dei dati
RDX e Windows Backup: semplice ed economica protezione dei datiPaolo Rossi
 
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQLMySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQLPar-Tec S.p.A.
 

Similar to Benchmarking Cloud Native PostgreSQL (20)

October 2009 - JBoss Cloud
October 2009 - JBoss CloudOctober 2009 - JBoss Cloud
October 2009 - JBoss Cloud
 
JBoss Clouds - JBug Roma october 2009
JBoss Clouds -  JBug Roma october 2009JBoss Clouds -  JBug Roma october 2009
JBoss Clouds - JBug Roma october 2009
 
Polyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDB
Polyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDBPolyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDB
Polyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDB
 
Marco Zani: Come dimensionare Magento per raggiungere i Key Performance Indic...
Marco Zani: Come dimensionare Magento per raggiungere i Key Performance Indic...Marco Zani: Come dimensionare Magento per raggiungere i Key Performance Indic...
Marco Zani: Come dimensionare Magento per raggiungere i Key Performance Indic...
 
Regione Toscana - Introdution to R Software
Regione Toscana - Introdution to R SoftwareRegione Toscana - Introdution to R Software
Regione Toscana - Introdution to R Software
 
Valutazione sperimentale di un database relazionale in ambiente cloud
Valutazione sperimentale di un database relazionale in ambiente cloudValutazione sperimentale di un database relazionale in ambiente cloud
Valutazione sperimentale di un database relazionale in ambiente cloud
 
Caso reale di migrazione da Windows a sistemi Open Source in azienda
Caso reale di migrazione da Windows a sistemi Open Source in aziendaCaso reale di migrazione da Windows a sistemi Open Source in azienda
Caso reale di migrazione da Windows a sistemi Open Source in azienda
 
Linuxday2013
Linuxday2013 Linuxday2013
Linuxday2013
 
MySQL Tech Tour 2015 - Progettare, installare e configurare MySQL Cluster
MySQL Tech Tour 2015 - Progettare, installare e configurare MySQL ClusterMySQL Tech Tour 2015 - Progettare, installare e configurare MySQL Cluster
MySQL Tech Tour 2015 - Progettare, installare e configurare MySQL Cluster
 
Glusterfs: un filesystem altamente versatile
Glusterfs: un filesystem altamente versatileGlusterfs: un filesystem altamente versatile
Glusterfs: un filesystem altamente versatile
 
Glusterfs: un filesystem altamente versatile
Glusterfs: un filesystem altamente versatileGlusterfs: un filesystem altamente versatile
Glusterfs: un filesystem altamente versatile
 
iot Saturday 2019 - PoC iot in 1 ora
iot Saturday 2019 - PoC iot in 1 oraiot Saturday 2019 - PoC iot in 1 ora
iot Saturday 2019 - PoC iot in 1 ora
 
PoC IoT in 1 ora
PoC IoT in 1 oraPoC IoT in 1 ora
PoC IoT in 1 ora
 
Web app slots and WebAPI versioning
Web app slots and WebAPI versioningWeb app slots and WebAPI versioning
Web app slots and WebAPI versioning
 
Web app slots and webapi versioning
Web app slots and webapi versioningWeb app slots and webapi versioning
Web app slots and webapi versioning
 
DbUp - A real case of database migration
DbUp - A real case of database migrationDbUp - A real case of database migration
DbUp - A real case of database migration
 
Kubernetes Core Concepts
Kubernetes Core ConceptsKubernetes Core Concepts
Kubernetes Core Concepts
 
Azure PaaS databases
Azure PaaS databasesAzure PaaS databases
Azure PaaS databases
 
RDX e Windows Backup: semplice ed economica protezione dei dati
RDX e Windows Backup: semplice ed economica protezione dei datiRDX e Windows Backup: semplice ed economica protezione dei dati
RDX e Windows Backup: semplice ed economica protezione dei dati
 
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQLMySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
 

More from EDB

Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSCloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSEDB
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenDie 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenEDB
 
Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube EDB
 
EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EDB
 
Las Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLLas Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLEDB
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLEDB
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?EDB
 
Data Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLData Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLEDB
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresEDB
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINEDB
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQLEDB
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLEDB
 
Psql is awesome!
Psql is awesome!Psql is awesome!
Psql is awesome!EDB
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB
 
Comment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesComment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesEDB
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13EDB
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLEDB
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJCloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJEDB
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLEDB
 
EDB Postgres & Tools in a Smart City Project
EDB Postgres & Tools in a Smart City ProjectEDB Postgres & Tools in a Smart City Project
EDB Postgres & Tools in a Smart City ProjectEDB
 

More from EDB (20)

Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSCloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenDie 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube
 
EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021
 
Las Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLLas Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQL
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
 
Data Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLData Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQL
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with Postgres
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAIN
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQL
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQL
 
Psql is awesome!
Psql is awesome!Psql is awesome!
Psql is awesome!
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJ
 
Comment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesComment sauvegarder correctement vos données
Comment sauvegarder correctement vos données
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQL
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJCloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJ
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQL
 
EDB Postgres & Tools in a Smart City Project
EDB Postgres & Tools in a Smart City ProjectEDB Postgres & Tools in a Smart City Project
EDB Postgres & Tools in a Smart City Project
 

Benchmarking Cloud Native PostgreSQL

  • 1. “ Perché dovrei avere un database su Kubernetes?
  • 2. “ Perché dovrei usare Postgres come database?
  • 3. “ Perché dovrei fare un benchmark del database prima di andare in produzione?
  • 5. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Francesco Canovai • PostgreSQL • Infrastruttura • Automazione • Testing • Kubernetes 5 Twitter: @fcanovai / @EDBPostgres
  • 6. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Argomenti • I “perché” • Com’è iniziato • Storage • Database • cnp-bench • Risultati • Conclusioni
  • 8. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Perché un database su Kubernetes Utilizzare al meglio un’infrastruttura a microservizi 8 ● Un microservizio dovrebbe essere il proprietario dei suoi dati ○ I dati devono essere organizzati in un singolo data store o database ○ Solo il servizio deve avere accesso ai dati ○ Gestione dello schema inclusa ● Riduce il Carico cognitivo del Team ○ “Software that fits in your head” (Dan North) ● Definire chiare interfacce di comunicazione tra microservizi ● In Kubernetes, le applicazioni e i database coesistono: ○ Tutto è un workload (incluso il database) ○ Container e microservizi sono parte della definizione di Cloud Native
  • 9. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Esempio di microservizi 9 Applicazioni web con backend PostgreSQL Rest API
  • 10. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved PostgreSQL popularity Source: DB-Engines.com, 2021 Source: Stack Overflow Developer Survey, 2020 Perché PostgreSQL? 10 2017 2018 2020 Most loved database Chi lo prova lo ama Most popular database
  • 11. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Feature 11 Versione ridotta ● Replica streaming nativa, logica e fisica, sincrona ed asincrona ● Continuous backup e point in time recovery ● Partizionamento dichiarativo ● Supporto JSON ● Estensioni (e.g. PostGIS) ● Query parallele ● INSERT .. ON CONFLICT DO UPDATE ● Supporto TLS e autenticazione con certificati ● SQL Standard (2016) ● DDL transazionali ● Ricerca full text nativa ● Tablespace ● ...
  • 12. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved PostgreSQL: architettura di replica 12 Primario e repliche tramite replica streaming fisica nativa ● PostgreSQL supporta in modo nativo l’architettura primary/standby ○ Evolutione della Crash Recovery e della Point-In-Time Recovery ○ Introdotta in PostgreSQL 8.2 con WAL shipping e Warm Standby ○ Migliorata in PostgreSQL 9.0 con WAL streaming e Hot Standby (replica sola lettura) ● Ulteriori miglioramenti: ○ Replica sincrona ○ Replica in cascata ○ Replica logica ● Robusta e affidabile, con ottimi risultati in termini di RPO e RTO
  • 13. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved 13 Due approcci a PostgreSQL su Kubernetes Operatore (con replica PostgreSQL) Container (con replica del file system)
  • 14. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Stato richiesto Stato attuale RW RW
  • 15. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Cloud Native PostgreSQL by EDB 15 Il migliore database open source sul migliore orchestratore di container open source ● Operatore proprietario, con una licenza di prova implicita di 30 giorni ● Operandi: ○ PostgreSQL ○ EDB Postgres Advanced Server ● Documentazione disponibile ○ docs.enterprisedb.io
  • 16. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Perché fare benchmark su PostgreSQL 16 Metodo scientifico ● Decisioni basate su dati e misurazioni ripetibili ○ “Lo sanno tutti” vs. “Perché le TPS osservate non sono sufficienti” ● Obiettivi: ○ Capacity planning e ottimizzazione dei costi ○ Prestazioni predicibili ● Prestazioni ○ Possono variare per molteplici fattori (hardware, software, network!) ○ Il database è pesantemente influenzato dallo storage (bottleneck) ● Prima di andare in produzione
  • 17. Parte 1 Come è iniziato
  • 18. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Un nuovo prodotto in 2ndQuadrant 18 L’esplorazione di Kubernetes inizia nel Q3/2019 ● Contesto: esperienza pluriennale su DevOps/Lean/Agile ● Portare PostgreSQL su Kubernetes ○ Cosa manca dentro PostgreSQL per un esperto Kubernetes? ○ Cosa manca in Kubernetes per un esperto PostgreSQL? ○ Esplorazione con approccio fail-fast ● Obiettivo: arrivare in Kubernetes allo stesso livello che abbiamo su PostgreSQL ○ Prima compagnia PostgreSQL a diventare Kubernetes Certified Service Provider ● Per le nostre esperienza, le prestazioni dello storage erano la priorità principale ○ Possiamo fare funzionare PostgreSQL in un Kubernetes su bare-metal?
  • 19. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved 19
  • 21. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Cosa si aspetta un database dallo storage? 21 In bare metal, VM e container ● Disponibilità ● Scalabilità ● Prestazioni ● Consistenza ● Durabilità
  • 22. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Storage e architetture 22 ● Antipattern K8s ● Accesso diretto allo storage del SO ○ Sul nodo worker ● Richieste degli utenti PostgreSQL ○ Architettura shared nothing ○ Prestazioni ○ Predicibilità ○ HA tramite replica Postgres Locale Network • Pattern K8s • Numerose soluzioni disponibili • HA tramite replica dello storage • Storage condiviso • Altri workload
  • 23. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved PostgreSQL e lo storage (versione semplificata) 23 Dove lo storage diventa critico per PostgreSQL ● Write Ahead Log (WAL), in passato xlog ○ Scritture sequenziali e fsync ● Scrittura degli shared buffers ○ Fatta dal checkpoint, dal bgwriter, o dal backend ○ Scritture random ● Letture di pagine ○ Letture random ● Table scan ○ Letture sequenziali
  • 24. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Cosa misurare 24 Metriche per la valutazione di uno storage ● Throughput: ○ Sequential read ○ Sequential write ○ Random read ○ Random write ● IOPS: ○ Limiti sul cloud
  • 25. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Come misurare 25 ● Il tool che abbiamo scelto per le misure ○ In passato abbiamo utilizzato bonnie++ ● Simula numerosi tipi di I/O ● Configurable ● Multi-piattaforma ○ Utilizzabile anche su Kubernetes ● Open Source ○ GNU GPL 2 ○ https://fio.readthedocs.io/ fio: Flexible I/O
  • 26. “ Se lo storage è lento il database sarà lento
  • 28. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Workload PostgreSQL 28 Tipi di carico di lavoro ● In-Memory ○ Il database entra interamente in RAM ○ Limitato da velocità di CPU e RAM ● OnLine Transactional Processing (OLTP) ○ Molte piccole transazioni concorrenti ○ Mix di inserimenti, letture e aggiornamenti ● OnLine Analytical Processing (OLAP) ○ Poche query complesse, principalmente in lettura, su dati storici ○ Usato per reportistica e business intelligence
  • 29. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Cosa misurare 29 Quali metriche usare per valutare le prestazioni del database? ● Ci siamo concentrati su: ○ Carico di lavoro OLTP ○ Dimensione del database superiore alla RAM ■ Questo ci costringe a lavorare sul disco ● Metrica scelta: ○ Transazioni al secondo (TPS)
  • 30. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Come misurare 30 pgbench ● Lo strumento che abbiamo scelto per il benchmark del database ● Parte del core di PostgreSQL ● Simula un carico di lavoro TPC-B like (OLTP) ● Configurabile ○ scale factor, numero di client e thread, durata, … ● Open Source, TPL ● Supporto per query custom ○ Niente batte l’applicazione reale
  • 32. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved cnp-bench 32 ● Una raccolta di Helm chart ○ Facili da eseguire ○ Facili da personalizzare ○ Facili da riprodurre ● Esecuzione di benchmark per cluster Cloud Native PostgreSQL (CNP) ○ Utilizza fio e pgbench ○ Misurazione di IOPS e TPS ● github.com/EnterpriseDB/cnp-bench
  • 33. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Fio benchmark 33 ● Creazione di un PVC ○ Scegliendo la storage class e la dimensione ● Crea una ConfigMap per il job fio ○ Specifica il tipo di workload da eseguire sul PVC ● Fio è eseguito come deployment ○ Effettua il benchmark ○ Serve i risultati
  • 34. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved values.yaml 34 pvcStorageClassName: default pvcSize: 2Gi nodeSelector: {} jobRW: read jobBs: 8k jobRuntime: 60 jobTimeBased: 1 jobSize: 1G jobIodepth: 32 jobDirect: 1 jobIoengine: libaio jobEndFsync: 1 jobLogAvgMsec: 1000
  • 35. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Risultati 35
  • 36. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved pgbench 36 ● Avvia un cluster Cloud Native PostgreSQL ○ Configurabile ○ Impostazioni di PostgreSQL diverse possono cambiare il risultato ● Esegue un job con pgbench ● I log di pgbench contengono i risultati
  • 37. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved values.yaml 37 cnpInstances: 1 cnpStorageClass: default cnpSize: 1Gi cnpImage: quay.io/enterprisedb/postgresql:13.3 cnpNodeSelector: workload: postgresql cnpPostgreSQLParameters: shared_buffers: '512MB' maintenance_work_mem: '128MB' pgbenchNodeSelector: workload: pgbench pgbenchScaleFactor: 1 pgbenchTime: 60 pgbenchClients: 1 pgbenchJobs: 1 pgbenchWarmTime: 0
  • 38. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Risultati 38 starting vacuum...end. transaction type: <builtin: TPC-B (sort of)> scaling factor: 1 query mode: simple number of clients: 1 number of threads: 1 duration: 60 s number of transactions actually processed: 23114 latency average = 2.596 ms tps = 385.225531 (including connections establishing) tps = 385.271092 (excluding connections establishing)
  • 40. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved AKS 40 ● Abbiamo eseguito dei test su AKS, con diverse combinazioni di VM dischi ● Le VM non sono definite solo da CPU e RAM ○ Diverse VM hanno limiti diversi per IOPS, larghezza di banda per I/O e rete ● Anche i dischi hanno i loro limiti di IOPS e banda ○ Alcuni dischi permettono di eccedere i limiti per breve tempo (burst)
  • 41. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved AKS 41 Network storage ● P10 ● P30 ● P80 Standard_E8d_v4 ● vCPU: 8 ● RAM: 64GB ● Network bandwidth: 4000 Mb/s Disk Size (GiB) BW (MiB/s) IOPS Burst P10 100 100 500 Yes P30 1000 200 5000 No P80 20000 900 20000 No
  • 42. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Benchmark fio: risultati 42 3600s - 8kb block size Disk Max BW (MiB/s) Max IOPS Seq Read Seq Write Rand Read Rand Write MB/s IOPS MB/s IOPS MB/s IOPS MB/s IOPS P10 100 500 483 58994 16.4 2003 452 55137 15.5 1960 P30 200 5000 85.3 10415 41.6 5082 42.7 5217 37.5 4575 P80 900 20000 81.3 9930 89.1 10881 92.6 11306 68.2 9655
  • 43. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Il burst 43 Scritture sequenziali sul P10 Max BW (MiB/s) Max IOPS Seq Write MB/s IOPS 100 500 16.4 2003
  • 44. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved La cache di lettura 44 Disk BW (MiB/s) IOPS Seq Read Seq Write Rand Read Rand Write MB/s IOPS MB/s IOPS MB/s IOPS MB/s IOPS P10 100 500 483 58994 16.4 2003 452 55137 15.5 1960 P10NC 100 500 16.3 1986 16.4 2003 16.3 1985 15.5 1952 P30 200 5000 85.3 10415 41.6 5082 42.7 5217 37.5 4575 P30NC 200 5000 41.7 5088 41.6 5082 41.7 5087 37.5 4580 P80 900 20000 81.3 9930 89.1 10881 92.6 11306 68.2 9655 P80NC 900 20000 88.3 10778 88.2 10795 90.7 11,074 68.3 9621
  • 45. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Durata: 1h Dimensioni diverse del DB per dischi diversi Configurazioni di PostgreSQL (comuni): ● shared_buffers: '16GB' ○ 64GB di RAM ● max_wal_size: '15GB' ● checkpoint_timeout: '900s' ● checkpoint_completion_target: '0.9' ● maintenance_work_mem: '2GB' Pgbench: risultati 45 Disk DB size (GB) TPS P10 71 1,499 P30 731 1,274 P80 1,490 1,051
  • 46. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Work in progress: storage locale 46 Standard_L8s_v2 CPU: 8 RAM: 64 Throughput: Max Read BW: 2000 MB/s Max Read IOPS: 400000 Disks: 1x1.92 TB NVME Seq Read Seq Write Rand Read Rand Write DB size (GB) TPS MB/s IOPS MB/s IOPS MB/s IOPS MB/s IOPS 1,142 139,370 696 84,996 1,070 130,587 262 32,010 732 2,082
  • 48. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Riepilogo degli argomenti 48 PostgreSQL su Kubernetes? Si può fare! ● Un metodo per effettuare benchmark di PostgreSQL su Kubernetes ● Degli strumenti open source per il benchmark ● Perché è importante fare benchmark dello storage e del database ● Usare cnp-bench per il benchmark di Cloud Native PostgreSQL: ○ github.com/EnterpriseDB/cnp-bench
  • 49. 2021 Copyright © EnterpriseDB Corporation All Rights Reserved Stiamo assumendo! • enterprisedb.com/careers • Numerose posizioni • Da remoto, in tutto il mondo • Nel nostro team: • GoLang Developer, Kubernetes • Automation engineer, DevOps/Kubernetes