On Wed, Nov 8, 2017 at 9:34 PM, Marcelo Kruger <marcelo.kruger@xxxxxxxxxxxxx> wrote:Hi Shreeyansh,Thank you for your help.The lag is not occurring in the recording of the archive in production, nor in sending to StandBy. The lag is occurring in the archive application in StandBy. And this slowness increases with running queries in the StandBy database.The process of recovering is consuming little CPU, and little I / O.postgres: startup process recovering 0000000100001B4300000006This parameter log_min_duration_statement should be changed on the StandBy server?The parameter should be changed On both master as well as slave as this result towards heavy load on the server causing slower execution of the queries due to higher resource consumption.This parameter normally set capturing bottleneck queries by setting the higher values to minimize the write activities and load on the servers.2017-11-08 12:09 GMT-02:00 Shreeyansh Dba <shreeyansh2014@xxxxxxxxx>:Hi Marcelo Kruger,On Wed, Nov 8, 2017 at 7:08 PM, Marcelo Kruger <marcelo.kruger@xxxxxxxxxxxxx> wrote:Good afternoon,I have two servers hosted on Azure with PostgreSQL 9.6 databases. One database is production, the other is standby.For replication I use stream replication between servers. However the application of the archives in the standby database is slow, always generating replication lag.The replication lag increases considerably when queries are performed on the StandBy database. I wonder if there is any setting that can be made to improve this performance.Server ProductionSO: CentOS Linux release 7.4.1708 (Core) 64BitsCPU: Intel(R) Xeon(R) CPU E5-2698B v3 @ 2.00GHz - 15 CoresMemory: 240GBI/O: 17TB RAID0 (17 Disks (1TB for disk) SSD with read and write cache enabled)Server StandBySO: CentOS Linux release 7.4.1708 (Core) 64BitsCPU: Intel(R) Xeon(R) CPU E5-2673 v3 @ 2.40GHz - 20 CoresMemory: 140GBI/O: 22TB RAID0 (22 Disks (1TB for disk) SSD with read and write cache enabled)Configuration PostgreSQL Productionpostgres.conflisten_addresses = '*'port = 5433max_connections = 2000superuser_reserved_connections = 3shared_buffers = 56GBwork_mem = 29360kBmaintenance_work_mem = 4GBautovacuum_work_mem = 8GBmax_stack_depth = 5MBdynamic_shared_memory_type = posixbgwriter_delay = 10msbgwriter_lru_maxpages = 700bgwriter_lru_multiplier = 2.0fsync = offsynchronous_commit = onfull_page_writes = offwal_buffers = 1500MBwal_writer_delay = 1mscheckpoint_timeout = 10minmax_wal_size = 4GBmin_wal_size = 2GBcheckpoint_completion_target = 0.9effective_cache_size = 168GBdefault_statistics_target = 500log_destination = 'csvlog'logging_collector = onlog_directory = 'pg_log'log_filename = 'postgresql-%w.log'log_file_mode = 0640log_truncate_on_rotation = onlog_rotation_age = 1dlog_rotation_size = 600MBlog_min_duration_statement = 0log_checkpoints = offlog_connections = offlog_disconnections = offlog_duration = offlog_line_prefix = '%t [%p]: [%l-1] db=%d,user=%u,app=%a,client=%h' log_lock_waits = onlog_timezone = 'Brazil/East'autovacuum = onlog_autovacuum_min_duration = -1autovacuum_max_workers = 12autovacuum_naptime = 30sautovacuum_vacuum_threshold = 20autovacuum_analyze_threshold = 20autovacuum_vacuum_scale_factor = 0.2autovacuum_analyze_scale_factor = 0.1 autovacuum_vacuum_cost_delay = 20autovacuum_vacuum_cost_limit = 800vacuum_cost_delay = 20vacuum_cost_limit = 800datestyle = 'iso, mdy'timezone = 'Brazil/East'lc_messages = 'en_US.UTF-8'lc_monetary = 'en_US.UTF-8'lc_numeric = 'en_US.UTF-8'lc_time = 'en_US.UTF-8'default_text_search_config = 'pg_catalog.english'max_locks_per_transaction = 256pgpool.pg_ctl = '/usr/pgsql-9.6/bin/pg_ctl'effective_io_concurrency = 10wal_level = hot_standbymax_wal_senders = 10max_replication_slots = 3wal_keep_segments = 38400Configuration PostgreSQL StandBypostgres.conflisten_addresses = '*'port = 5433max_connections = 2000superuser_reserved_connections = 3shared_buffers = 10GBwork_mem = 183500kBmaintenance_work_mem = 4GBautovacuum_work_mem = 8GBmax_stack_depth = 5MBdynamic_shared_memory_type = posixbgwriter_delay = 10msbgwriter_lru_maxpages = 700bgwriter_lru_multiplier = 2.0fsync = offsynchronous_commit = onfull_page_writes = offwal_buffers = 16MBwal_writer_delay = 1mscheckpoint_timeout = 10minmax_wal_size = 4GBmin_wal_size = 2GBcheckpoint_completion_target = 0.9effective_cache_size = 104GBdefault_statistics_target = 500log_destination = 'csvlog'logging_collector = onlog_directory = 'pg_log'log_filename = 'postgresql-%w.log'log_file_mode = 0640log_truncate_on_rotation = onlog_rotation_age = 1dlog_rotation_size = 600MBlog_min_duration_statement = 0log_checkpoints = offlog_connections = offlog_disconnections = offlog_duration = offlog_line_prefix = '%t [%p]: [%l-1] db=%d,user=%u,app=%a,client=%h' log_lock_waits = onlog_timezone = 'Brazil/East'autovacuum = onlog_autovacuum_min_duration = -1autovacuum_max_workers = 3autovacuum_naptime = 30sautovacuum_vacuum_threshold = 20autovacuum_analyze_threshold = 20autovacuum_vacuum_scale_factor = 0.2autovacuum_analyze_scale_factor = 0.1 autovacuum_vacuum_cost_delay = 20autovacuum_vacuum_cost_limit = 800vacuum_cost_delay = 20vacuum_cost_limit = 800datestyle = 'iso, mdy'timezone = 'Brazil/East'lc_messages = 'en_US.UTF-8'lc_monetary = 'en_US.UTF-8'lc_numeric = 'en_US.UTF-8'lc_time = 'en_US.UTF-8'default_text_search_config = 'pg_catalog.english'max_locks_per_transaction = 256pgpool.pg_ctl = '/usr/pgsql-9.6/bin/pg_ctl'effective_io_concurrency = 10max_worker_processes = 18hot_standby = onhot_standby_feedback = onrecovery.confstandby_mode = 'on'primary_slot_name = 'replicacao'primary_conninfo = 'host=bdreplica00 port=5433 user=replicator password='trigger_file = '/var/lib/pgsql/9.6/data/master_db.conf' --Data Integration
Office: +55 48 3333-2030 | Mobile: +55 48 999679585
R. Patrício Farias, 131 - Itacorubi - Florianópolis - 3º andar | 88034-132 | Santa Catarina, Brasil
São Paulo | Florianópolis | New York
Conteúdo confidencial. Caso você não seja o real destinatário deste e-mail por favor notifique o remetente e elimine esta mensagem. Privileged and confidential. If you are not the intended addressee of this e-mail please notify the sender and promptly delete this message.
From server configuration details provided, looks like a heavy trans DB & more logging enabled which might be resulting more write act on Master and Slave.At our first glance, we see log_min_duration_statement is set to 0 which might be writing all the queries into the log resulting heavy writing activity that maybe cause for replication lag.Hope this helps you.----Data Integration
Office: +55 48 3333-2030 | Mobile: +55 48 999679585
R. Patrício Farias, 131 - Itacorubi - Florianópolis - 3º andar | 88034-132 | Santa Catarina, Brasil
São Paulo | Florianópolis | New York
Conteúdo confidencial. Caso você não seja o real destinatário deste e-mail por favor notifique o remetente e elimine esta mensagem. Privileged and confidential. If you are not the intended addressee of this e-mail please notify the sender and promptly delete this message.
--
Data Integration
Office: +55 48 3333-2030 | Mobile: +55 48 999679585
R. Patrício Farias, 131 - Itacorubi - Florianópolis - 3º andar | 88034-132 | Santa Catarina, Brasil
São Paulo | Florianópolis | New York
Conteúdo confidencial. Caso você não seja o real destinatário deste e-mail por favor notifique o remetente e elimine esta mensagem. Privileged and confidential. If you are not the intended addressee of this e-mail please notify the sender and promptly delete this message.