SlideShare a Scribd company logo
Pavel Konotopov - kakoka@gmail.com
Leoinid Albrecht - lalbrekht@gmail.com
DBA team
InCountry
Storing regulated data in 62 countries of the World
Idea
•Let's create and provide
the global business with an
infrastructure for the local
storage of regulated data
• Infrastructure must meet certain
requirements
2
PII Data
• PII Data Laws
Personal data: the ability to uniquely identify a person
"... any information relating directly or indirectly to a specific
or determinable natural person - the subject of personal data ..."
• PII data processing
set of actions performed with personal data, including collection, recording, systematization,
accumulation, storage, clarification, change, extraction, use, transfer, depersonalization, blocking,
deletion, destruction
3
Requirements
• Store data in the country of its origin;
• Geo-distributed infrastructure;
• At the same time, the data cannot cross the borders of the country of origin;
• Compliance with industry safety standards: SOC, PCI DSS, HIPAA, ISO ...;
• Compliance with the laws of the states: FZ152, GDPR, CCPA ...
• Ability to integrate into ready-made systems
• Encryption support
• Acceptable speed
• Cheap (we are a startup)
business
architect
4
Products
• REST API
- no extra effort
- modifies data inside an existing service
• SDK
- Java, PHP, Python, Node.js SDKs
- Self-service
- Client-side encryption
• Border proxy
5
Service Architecture
User App REST API
PoP InCountry
DB Cluster
6
PoP
FLIGHT RECORD
GDPR
PROFILE
PAYMENT
TRANSACTION
App
Your frontend web service
uses actual data in-country
Customer ID: 98765
First Name: John
Last Name: Smith
SS#: 123-45-6789
Phone: +1-415-555-1212
Your backend web
service uses redacted data
Customer ID: 98765
First Name: HashKey.fname
Last Name: HashKey.lname
SS#: HashKey.ss
Phone: HaskKey.phone
7
Infrastructure
•Points of presence - 62 countries
• 30% Cloud
• 70% BARE-METAL
• Immediately forget about the K8s
• 2 data centers in the country
• 4 to 8 servers per country
•Centralized deployment
infrastructure
•Centralized management
infrastructure
•Security
•Monitoring
8
Infrastructure
Nomad cluster
Consul cluster
Zabbix EFK Grafana
Jenkins
Regional HUB
EDGE
Application
Database
Backup
EDGE
Application
Database
Backup
Country of presence
DC1 DC2
Regional hub
9
Cheap vs expensive vs reasonable
•Use Open Source and make Enterprise
•But there is a problem
OpenSource + DevOps = T x $$$
Limited OpenSource + Devops = $ + T x $
Non-OpenSource + DevOps = $$$ + T x $
+ =
10
Tech Stack
• Terraform/Packer/Ansible/AWX
• Consul – discovery service
• Nomad – scheduler
• Vault – repository of secrets
• Docker – containerization
• Jenkins – CI/CD
• Nginx
• PostgreSQL/Pgbouncer/Patroni
• Zabbix/ElasticSearch/Fluentd/Grafana/Kibana
•JumpCloud – LDAP
•Cisco VPN
•OpsGenie – alerting
•JFROG artifactory – storage
of docker images
OpenSource Not OpenSource
11
●Geo-distribution
●2 DCs in one country
●High Availability
●Sync Replica
●Auto Failover
●Protection from split brain. Fencing.
12
PostgreSQL Tasks
●PostgreSQL
●pgbounсer - connection puller
●Patroni - a cluster management mechanism
●HashiCorp Consul:
● stores cluster status information
● stores the current cluster configuration
● Consul Templates
●HashiCorp Nomad:
● Automatically raises containers when they fail
●HashiCorp Vault - stores secrets, static and dynamic roles 13
PostgreSQL Tools
14
PostgreSQL: Deployment
DB Server
●As an out-of-the-box solution PostgreSQL does not have
automatic failover
●Daemon running next to PostgreSQL
●Interacts with DCS
●Patroni daemon decides on promotion / demotion
●Config in the form of YAML
●patronictl - convenient tool not only for DBA
15
PostgreSQL: Patroni
●Cons
● You can’t just stop the container.
● In some “special” cases, the
container is cut down in an
unexpected place.
16
●Pros
● Centralized management location
● Declarative approach
● Convenient resource allocation for the
container
PostgreSQL: Nomad
update {
max_parallel = 1
min_healthy_time = "10s"
healthy_deadline = "3m"
progress_deadline = "10m"
auto_revert = false
canary = 0
}
…
resources {
cpu = ${NOMAD_RESOURCES_CPU}
memory = ${NOMAD_RESOURCES_MEM}
network {
mbits = 1
port "${NOMAD_POSTGRES_SERVICE_NAME}" {
static = “${NOMAD_POSTGRES_PORT}"…
17
Nomad.TemplateFile
port_map {
${NOMAD_PATRONI_SERVICE_NAME} = “$
{NOMAD_PATRONI_PORT}"
}
port_map {
${NOMAD_POSTGRES_SERVICE_NAME} = “$
{NOMAD_POSTGRES_PORT}”
}
mounts = [
{
type = "bind"
source = "/etc/patroni/patroni.yml"
target =
"/home/postgres/.config/patroni/patroni.yml"
readonly = true
},
18
● Persistent Storage for database files
● Facilitate container with multi-stage build
● ~70-90 Mb image
● As a result, acceleration of delivery to the region
● It lives well if the container does not fall
● Virtually no overhead
PostgreSQL: Docker
19
PostgreSQL: HashiCorp Vault
Vault
PostgreSQLUser/Application
● Keeps static secrets
● Allows serving static roles
● Comply with password update policy
● Can create dynamic roles
● Such roles are created for a given time when
querying Vault
● Have the necessary rights
● Deleted after Expiration
1. GET Creds 2. CREATE ROLE
3. SEND Creds
4. Login
20
● Slots enabled by default. But don’t forget about wal_keep_segments
● Synchronous replication specificities:
● network is a bottleneck
● synchronous mode
● maximum_lag_on_failover: 1048576 (1M)
PostgreSQL: Replication
21
●pg_probackup
●Validation
●Logging and Monitoring
●Customized retention policies for customers
●Specifics of using two DCs:
● Dual WAL archive
● Double backup archive
PostgreSQL: Backup
22
PostgreSQL: Backup
DC1
DB Master
Backup
DC2
DB StandBy
Backup
WAL push
WAL
Archive
Backup
storage
WAL
Archive
Backup
storage
Backup Fetch
23
• By default, a replica is created using the pg_basebackup utility.
• You can override this behavior with the ‘create_replica_methods’ parameter
postgresql:
create_replica_methods:
- probackup
- basebackup
probackup:
command: "ssh dbbackup@192.168.0.250 ‘bash /var/backup/pg_restore.sh'"
no_params: True
basebackup:
max-rate: '100M'
PostgreSQL: Backup
24
● The ability to recover from backup to any point by:
● Time
● Transaction id (xid)
● Transactional Log Entry LSN
● A rare occurrence with a synchronous replica, but you need to prepare:
bootstrap:
method: probackup
probackup:
command: ssh dbbackup@backup 'bash /var/backup/pg_restore.sh'
keep_existing_recovery_conf: false
recovery_conf:
recovery_target_timeline: latest
restore_command: pg_probackup archive-get -B /var/backup --instance db-mt --remote-user=dbbackup
--wal-file-path %p --wal-file-name %f —remote-host=255.255.255.255
PostgreSQL: cluster recovery
25
● Docker image for minimal launch
● Backup script from backup
● Minimum postgresql.conf to start
● Checking the success of the launch
● docker exec pgvalid pg_dump -h localhost -U postgres > /dev/null
● Service table for comparing data before and after backup
● amcheck
● CREATE EXTENSION amcheck
● pg_probackup checkdb —amcheck —heapallindexed
● We log and monitor every action and its success (failure).
PostgreSQL: Validation
● Everything related to Consul:
● Network problems in one DC
● Not available from both DCs
● Replication and HA issues. Frequent failures during network
outages
● Unexpected container restart
Troubleshooting
Troubleshooting: Distances
27
Troubleshooting: Audit
• Personally identifiable information in the logs
• Pgaudit - missing
• DB Api - stored procedures
• Access limitation
• We give rights only to those who need
them
• Choosing data centers that are certified
(PCI DSS)
Project Team
• Architecture Team
• Developer Team
• DevOps
• CloudOps/DevOps
• SRE
• Monitoring Team
• DBA Team
• Security Team
• Application Security Team
• QA and Performance Testing Team
• NOC, SOC
Всё. Осталось вкрутить лампочку.
29
DBA role
•DBA role:
• Little Architect
• Little DevOps
• Little SecOps
• A bit of monitoring
• A bit of QA & Perf
• Little Developer
• Linux Administrator
30
inCountry team

More Related Content

What's hot

Ceph Object Storage Performance Secrets and Ceph Data Lake Solution
Ceph Object Storage Performance Secrets and Ceph Data Lake SolutionCeph Object Storage Performance Secrets and Ceph Data Lake Solution
Ceph Object Storage Performance Secrets and Ceph Data Lake Solution
Karan Singh
 
Understanding blue store, Ceph's new storage backend - Tim Serong, SUSE
Understanding blue store, Ceph's new storage backend - Tim Serong, SUSEUnderstanding blue store, Ceph's new storage backend - Tim Serong, SUSE
Understanding blue store, Ceph's new storage backend - Tim Serong, SUSE
OpenStack
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
Felix Geisendörfer
 
Integration of neutron, nova and designate how to use it and how to configur...
Integration of neutron, nova and designate  how to use it and how to configur...Integration of neutron, nova and designate  how to use it and how to configur...
Integration of neutron, nova and designate how to use it and how to configur...
Miguel Lavalle
 
Infrastructure as Code in Google Cloud
Infrastructure as Code in Google CloudInfrastructure as Code in Google Cloud
Infrastructure as Code in Google Cloud
Radek Simko
 
Terraforming the Kubernetes Land
Terraforming the Kubernetes LandTerraforming the Kubernetes Land
Terraforming the Kubernetes Land
Radek Simko
 
Designate - Operators Deep Dive
Designate - Operators Deep DiveDesignate - Operators Deep Dive
Designate - Operators Deep Dive
Graham Hayes
 
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ontico
 
Ceph Performance and Sizing Guide
Ceph Performance and Sizing GuideCeph Performance and Sizing Guide
Ceph Performance and Sizing Guide
Jose De La Rosa
 
Designate Installation Workshop
Designate Installation WorkshopDesignate Installation Workshop
Designate Installation Workshop
Graham Hayes
 
Background Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbitBackground Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbit
Redis Labs
 
Intorduce to Ceph
Intorduce to CephIntorduce to Ceph
Intorduce to Ceph
kao kuo-tung
 
Ceph Day KL - Bluestore
Ceph Day KL - Bluestore Ceph Day KL - Bluestore
Ceph Day KL - Bluestore
Ceph Community
 
Node.js in production
Node.js in productionNode.js in production
Node.js in production
Felix Geisendörfer
 
Node.js - A Quick Tour II
Node.js - A Quick Tour IINode.js - A Quick Tour II
Node.js - A Quick Tour II
Felix Geisendörfer
 
Designate: An Overview
Designate: An OverviewDesignate: An Overview
Designate: An Overview
Graham Hayes
 
BlueStore, A New Storage Backend for Ceph, One Year In
BlueStore, A New Storage Backend for Ceph, One Year InBlueStore, A New Storage Backend for Ceph, One Year In
BlueStore, A New Storage Backend for Ceph, One Year In
Sage Weil
 
BlueStore: a new, faster storage backend for Ceph
BlueStore: a new, faster storage backend for CephBlueStore: a new, faster storage backend for Ceph
BlueStore: a new, faster storage backend for Ceph
Sage Weil
 
Build an High-Performance and High-Durable Block Storage Service Based on Ceph
Build an High-Performance and High-Durable Block Storage Service Based on CephBuild an High-Performance and High-Durable Block Storage Service Based on Ceph
Build an High-Performance and High-Durable Block Storage Service Based on Ceph
Rongze Zhu
 
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
OpenCredo
 

What's hot (20)

Ceph Object Storage Performance Secrets and Ceph Data Lake Solution
Ceph Object Storage Performance Secrets and Ceph Data Lake SolutionCeph Object Storage Performance Secrets and Ceph Data Lake Solution
Ceph Object Storage Performance Secrets and Ceph Data Lake Solution
 
Understanding blue store, Ceph's new storage backend - Tim Serong, SUSE
Understanding blue store, Ceph's new storage backend - Tim Serong, SUSEUnderstanding blue store, Ceph's new storage backend - Tim Serong, SUSE
Understanding blue store, Ceph's new storage backend - Tim Serong, SUSE
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
 
Integration of neutron, nova and designate how to use it and how to configur...
Integration of neutron, nova and designate  how to use it and how to configur...Integration of neutron, nova and designate  how to use it and how to configur...
Integration of neutron, nova and designate how to use it and how to configur...
 
Infrastructure as Code in Google Cloud
Infrastructure as Code in Google CloudInfrastructure as Code in Google Cloud
Infrastructure as Code in Google Cloud
 
Terraforming the Kubernetes Land
Terraforming the Kubernetes LandTerraforming the Kubernetes Land
Terraforming the Kubernetes Land
 
Designate - Operators Deep Dive
Designate - Operators Deep DiveDesignate - Operators Deep Dive
Designate - Operators Deep Dive
 
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
 
Ceph Performance and Sizing Guide
Ceph Performance and Sizing GuideCeph Performance and Sizing Guide
Ceph Performance and Sizing Guide
 
Designate Installation Workshop
Designate Installation WorkshopDesignate Installation Workshop
Designate Installation Workshop
 
Background Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbitBackground Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbit
 
Intorduce to Ceph
Intorduce to CephIntorduce to Ceph
Intorduce to Ceph
 
Ceph Day KL - Bluestore
Ceph Day KL - Bluestore Ceph Day KL - Bluestore
Ceph Day KL - Bluestore
 
Node.js in production
Node.js in productionNode.js in production
Node.js in production
 
Node.js - A Quick Tour II
Node.js - A Quick Tour IINode.js - A Quick Tour II
Node.js - A Quick Tour II
 
Designate: An Overview
Designate: An OverviewDesignate: An Overview
Designate: An Overview
 
BlueStore, A New Storage Backend for Ceph, One Year In
BlueStore, A New Storage Backend for Ceph, One Year InBlueStore, A New Storage Backend for Ceph, One Year In
BlueStore, A New Storage Backend for Ceph, One Year In
 
BlueStore: a new, faster storage backend for Ceph
BlueStore: a new, faster storage backend for CephBlueStore: a new, faster storage backend for Ceph
BlueStore: a new, faster storage backend for Ceph
 
Build an High-Performance and High-Durable Block Storage Service Based on Ceph
Build an High-Performance and High-Durable Block Storage Service Based on CephBuild an High-Performance and High-Durable Block Storage Service Based on Ceph
Build an High-Performance and High-Durable Block Storage Service Based on Ceph
 
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
 

Similar to Building the Enterprise infrastructure with PostgreSQL as the basis for storing personal data

Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
grooverdan
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
Kris Buytaert
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production
Paris Data Engineers !
 
6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production 6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production
Hung Lin
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
dotCloud
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Docker, Inc.
 
MySQL HA with Pacemaker
MySQL HA with  PacemakerMySQL HA with  Pacemaker
MySQL HA with Pacemaker
Kris Buytaert
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Aleksey Asiutin
 
The Accidental DBA
The Accidental DBAThe Accidental DBA
The Accidental DBA
PostgreSQL Experts, Inc.
 
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhereNew Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
Rodrique Heron
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotCloud
daoswald
 
Linux-HA with Pacemaker
Linux-HA with PacemakerLinux-HA with Pacemaker
Linux-HA with Pacemaker
Kris Buytaert
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
Kris Buytaert
 
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloudOpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
Netcetera
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
tomasbart
 
Oracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and HowOracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and How
Seth Miller
 
Managing Terraform Module Versioning and Dependencies
Managing Terraform Module Versioning and Dependencies Managing Terraform Module Versioning and Dependencies
Managing Terraform Module Versioning and Dependencies
Nebulaworks
 
Docker tlv
Docker tlvDocker tlv
Docker tlv
Ariel Moskovich
 
Big Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and MesosBig Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and Mesos
Heiko Loewe
 
Declarative & workflow based infrastructure with Terraform
Declarative & workflow based infrastructure with TerraformDeclarative & workflow based infrastructure with Terraform
Declarative & workflow based infrastructure with Terraform
Radek Simko
 

Similar to Building the Enterprise infrastructure with PostgreSQL as the basis for storing personal data (20)

Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production
 
6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production 6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
 
MySQL HA with Pacemaker
MySQL HA with  PacemakerMySQL HA with  Pacemaker
MySQL HA with Pacemaker
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
 
The Accidental DBA
The Accidental DBAThe Accidental DBA
The Accidental DBA
 
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhereNew Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotCloud
 
Linux-HA with Pacemaker
Linux-HA with PacemakerLinux-HA with Pacemaker
Linux-HA with Pacemaker
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloudOpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Oracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and HowOracle RAC and Docker: The Why and How
Oracle RAC and Docker: The Why and How
 
Managing Terraform Module Versioning and Dependencies
Managing Terraform Module Versioning and Dependencies Managing Terraform Module Versioning and Dependencies
Managing Terraform Module Versioning and Dependencies
 
Docker tlv
Docker tlvDocker tlv
Docker tlv
 
Big Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and MesosBig Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and Mesos
 
Declarative & workflow based infrastructure with Terraform
Declarative & workflow based infrastructure with TerraformDeclarative & workflow based infrastructure with Terraform
Declarative & workflow based infrastructure with Terraform
 

Recently uploaded

Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
mahaffeycheryld
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
upoux
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
Yasser Mahgoub
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
ycwu0509
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
edwin408357
 

Recently uploaded (20)

Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
 

Building the Enterprise infrastructure with PostgreSQL as the basis for storing personal data

  • 1. Pavel Konotopov - kakoka@gmail.com Leoinid Albrecht - lalbrekht@gmail.com DBA team InCountry Storing regulated data in 62 countries of the World
  • 2. Idea •Let's create and provide the global business with an infrastructure for the local storage of regulated data • Infrastructure must meet certain requirements 2
  • 3. PII Data • PII Data Laws Personal data: the ability to uniquely identify a person "... any information relating directly or indirectly to a specific or determinable natural person - the subject of personal data ..." • PII data processing set of actions performed with personal data, including collection, recording, systematization, accumulation, storage, clarification, change, extraction, use, transfer, depersonalization, blocking, deletion, destruction 3
  • 4. Requirements • Store data in the country of its origin; • Geo-distributed infrastructure; • At the same time, the data cannot cross the borders of the country of origin; • Compliance with industry safety standards: SOC, PCI DSS, HIPAA, ISO ...; • Compliance with the laws of the states: FZ152, GDPR, CCPA ... • Ability to integrate into ready-made systems • Encryption support • Acceptable speed • Cheap (we are a startup) business architect 4
  • 5. Products • REST API - no extra effort - modifies data inside an existing service • SDK - Java, PHP, Python, Node.js SDKs - Self-service - Client-side encryption • Border proxy 5
  • 6. Service Architecture User App REST API PoP InCountry DB Cluster 6
  • 7. PoP FLIGHT RECORD GDPR PROFILE PAYMENT TRANSACTION App Your frontend web service uses actual data in-country Customer ID: 98765 First Name: John Last Name: Smith SS#: 123-45-6789 Phone: +1-415-555-1212 Your backend web service uses redacted data Customer ID: 98765 First Name: HashKey.fname Last Name: HashKey.lname SS#: HashKey.ss Phone: HaskKey.phone 7
  • 8. Infrastructure •Points of presence - 62 countries • 30% Cloud • 70% BARE-METAL • Immediately forget about the K8s • 2 data centers in the country • 4 to 8 servers per country •Centralized deployment infrastructure •Centralized management infrastructure •Security •Monitoring 8
  • 9. Infrastructure Nomad cluster Consul cluster Zabbix EFK Grafana Jenkins Regional HUB EDGE Application Database Backup EDGE Application Database Backup Country of presence DC1 DC2 Regional hub 9
  • 10. Cheap vs expensive vs reasonable •Use Open Source and make Enterprise •But there is a problem OpenSource + DevOps = T x $$$ Limited OpenSource + Devops = $ + T x $ Non-OpenSource + DevOps = $$$ + T x $ + = 10
  • 11. Tech Stack • Terraform/Packer/Ansible/AWX • Consul – discovery service • Nomad – scheduler • Vault – repository of secrets • Docker – containerization • Jenkins – CI/CD • Nginx • PostgreSQL/Pgbouncer/Patroni • Zabbix/ElasticSearch/Fluentd/Grafana/Kibana •JumpCloud – LDAP •Cisco VPN •OpsGenie – alerting •JFROG artifactory – storage of docker images OpenSource Not OpenSource 11
  • 12. ●Geo-distribution ●2 DCs in one country ●High Availability ●Sync Replica ●Auto Failover ●Protection from split brain. Fencing. 12 PostgreSQL Tasks
  • 13. ●PostgreSQL ●pgbounсer - connection puller ●Patroni - a cluster management mechanism ●HashiCorp Consul: ● stores cluster status information ● stores the current cluster configuration ● Consul Templates ●HashiCorp Nomad: ● Automatically raises containers when they fail ●HashiCorp Vault - stores secrets, static and dynamic roles 13 PostgreSQL Tools
  • 15. ●As an out-of-the-box solution PostgreSQL does not have automatic failover ●Daemon running next to PostgreSQL ●Interacts with DCS ●Patroni daemon decides on promotion / demotion ●Config in the form of YAML ●patronictl - convenient tool not only for DBA 15 PostgreSQL: Patroni
  • 16. ●Cons ● You can’t just stop the container. ● In some “special” cases, the container is cut down in an unexpected place. 16 ●Pros ● Centralized management location ● Declarative approach ● Convenient resource allocation for the container PostgreSQL: Nomad
  • 17. update { max_parallel = 1 min_healthy_time = "10s" healthy_deadline = "3m" progress_deadline = "10m" auto_revert = false canary = 0 } … resources { cpu = ${NOMAD_RESOURCES_CPU} memory = ${NOMAD_RESOURCES_MEM} network { mbits = 1 port "${NOMAD_POSTGRES_SERVICE_NAME}" { static = “${NOMAD_POSTGRES_PORT}"… 17 Nomad.TemplateFile port_map { ${NOMAD_PATRONI_SERVICE_NAME} = “$ {NOMAD_PATRONI_PORT}" } port_map { ${NOMAD_POSTGRES_SERVICE_NAME} = “$ {NOMAD_POSTGRES_PORT}” } mounts = [ { type = "bind" source = "/etc/patroni/patroni.yml" target = "/home/postgres/.config/patroni/patroni.yml" readonly = true },
  • 18. 18 ● Persistent Storage for database files ● Facilitate container with multi-stage build ● ~70-90 Mb image ● As a result, acceleration of delivery to the region ● It lives well if the container does not fall ● Virtually no overhead PostgreSQL: Docker
  • 19. 19 PostgreSQL: HashiCorp Vault Vault PostgreSQLUser/Application ● Keeps static secrets ● Allows serving static roles ● Comply with password update policy ● Can create dynamic roles ● Such roles are created for a given time when querying Vault ● Have the necessary rights ● Deleted after Expiration 1. GET Creds 2. CREATE ROLE 3. SEND Creds 4. Login
  • 20. 20 ● Slots enabled by default. But don’t forget about wal_keep_segments ● Synchronous replication specificities: ● network is a bottleneck ● synchronous mode ● maximum_lag_on_failover: 1048576 (1M) PostgreSQL: Replication
  • 21. 21 ●pg_probackup ●Validation ●Logging and Monitoring ●Customized retention policies for customers ●Specifics of using two DCs: ● Dual WAL archive ● Double backup archive PostgreSQL: Backup
  • 22. 22 PostgreSQL: Backup DC1 DB Master Backup DC2 DB StandBy Backup WAL push WAL Archive Backup storage WAL Archive Backup storage Backup Fetch
  • 23. 23 • By default, a replica is created using the pg_basebackup utility. • You can override this behavior with the ‘create_replica_methods’ parameter postgresql: create_replica_methods: - probackup - basebackup probackup: command: "ssh dbbackup@192.168.0.250 ‘bash /var/backup/pg_restore.sh'" no_params: True basebackup: max-rate: '100M' PostgreSQL: Backup
  • 24. 24 ● The ability to recover from backup to any point by: ● Time ● Transaction id (xid) ● Transactional Log Entry LSN ● A rare occurrence with a synchronous replica, but you need to prepare: bootstrap: method: probackup probackup: command: ssh dbbackup@backup 'bash /var/backup/pg_restore.sh' keep_existing_recovery_conf: false recovery_conf: recovery_target_timeline: latest restore_command: pg_probackup archive-get -B /var/backup --instance db-mt --remote-user=dbbackup --wal-file-path %p --wal-file-name %f —remote-host=255.255.255.255 PostgreSQL: cluster recovery
  • 25. 25 ● Docker image for minimal launch ● Backup script from backup ● Minimum postgresql.conf to start ● Checking the success of the launch ● docker exec pgvalid pg_dump -h localhost -U postgres > /dev/null ● Service table for comparing data before and after backup ● amcheck ● CREATE EXTENSION amcheck ● pg_probackup checkdb —amcheck —heapallindexed ● We log and monitor every action and its success (failure). PostgreSQL: Validation
  • 26. ● Everything related to Consul: ● Network problems in one DC ● Not available from both DCs ● Replication and HA issues. Frequent failures during network outages ● Unexpected container restart Troubleshooting
  • 28. Troubleshooting: Audit • Personally identifiable information in the logs • Pgaudit - missing • DB Api - stored procedures • Access limitation • We give rights only to those who need them • Choosing data centers that are certified (PCI DSS)
  • 29. Project Team • Architecture Team • Developer Team • DevOps • CloudOps/DevOps • SRE • Monitoring Team • DBA Team • Security Team • Application Security Team • QA and Performance Testing Team • NOC, SOC Всё. Осталось вкрутить лампочку. 29
  • 30. DBA role •DBA role: • Little Architect • Little DevOps • Little SecOps • A bit of monitoring • A bit of QA & Perf • Little Developer • Linux Administrator 30