Financial Infrastructure · DevOps · Boston

Engineering inside
financial services.

Ten years across private equity, retail, and asset management. Real technical experience covering infrastructure, cloud, security, and trading systems. Written plainly to help other engineers navigate this world.

Michael Harlow
Michael Harlow // sys.ghost  ·  Boston, MA
☕ Buy me a coffee
Latest post
Every engineering org I talk to is running AI agents somewhere in production now. Almost none of them have figured out how to operate them the way we operate everything else that touches customer data.
Jul 14, 2026 · 11 min read
Read →
Latest post
Every engineering org I talk to is running AI agents somewhere in production now. Almost none of them have figured out how to operate them the way we operate everything else that touches customer data.
Jul 14, 2026 · 11 min read
Read →
All posts

Archive

We scheduled a Technology Connect event for our engineering team and built a lineup of games around AI and infrastructure topics. Here's how we put it together and what I'd do differently.
← Back to posts
Infrastructure Apr 12, 2026 · 12 min read

Setting Up PostgreSQL Streaming Replication from Scratch

Setting Up PostgreSQL Streaming Replication from Scratch

This is a step-by-step walkthrough of setting up PostgreSQL streaming replication. I wrote it because every guide I found when I was doing this for the first time either skipped steps or assumed knowledge I didn't have yet. This one won't.

What you'll end up with: a primary PostgreSQL server accepting reads and writes, and a standby server that stays in sync with every change in near real-time. If the primary fails, you can promote the standby to take over.

What you need: two servers (or VMs) running the same Linux distro, PostgreSQL installed on both, network access between them. I'll use Ubuntu 22.04 and PostgreSQL 15 throughout.

A quick explanation of how replication works

PostgreSQL streaming replication works by having the primary server continuously send its write-ahead log (WAL) to the standby. The WAL is essentially a record of every change made to the database - every insert, update, delete. The standby replays those changes as they arrive, keeping itself in sync.

Think of it like a very fast, continuous backup that you can actually read from.

Step 1: Set up the primary server

First, check your PostgreSQL version and confirm it's running:

psql --version
sudo systemctl status postgresql

Open the main PostgreSQL config file. The path depends on your version:

sudo nano /etc/postgresql/15/main/postgresql.conf

Find and set these values. They may be commented out - remove the # and update the value:

listen_addresses = '*'
wal_level = replica
max_wal_senders = 3
wal_keep_size = 512

wallevel = replica tells PostgreSQL to include enough information in the WAL for replication. maxwalsenders is the maximum number of standby connections. walkeep_size is how much WAL to keep on disk (in MB) so a briefly-disconnected standby can catch up.

Step 2: Create a replication user

PostgreSQL requires a dedicated user for replication connections. Do not use your superuser.

sudo -u postgres psql

Inside psql:

CREATE USER replicator WITH REPLICATION LOGIN PASSWORD 'choose-a-strong-password';
\q

Step 3: Configure access control on the primary

Open pg_hba.conf - this file controls who can connect to PostgreSQL and how:

sudo nano /etc/postgresql/15/main/pg_hba.conf

Add this line at the bottom, replacing STANDBY_IP with your standby server's IP address:

host    replication     replicator      STANDBY_IP/32          md5

This allows the replicator user to connect from the standby server specifically for replication.

Restart PostgreSQL to apply all config changes:

sudo systemctl restart postgresql

Verify it's listening on all interfaces:

sudo ss -tlnp | grep 5432

You should see 0.0.0.0:5432 in the output.

Step 4: Take a base backup on the standby

Now move to the standby server.

Stop PostgreSQL if it's running, and clear the data directory. This is destructive - the standby's data directory gets replaced entirely with a copy from the primary.

sudo systemctl stop postgresql
sudo rm -rf /var/lib/postgresql/15/main/*

Use pgbasebackup to copy the primary's data to the standby. Replace PRIMARYIP with your primary's IP:

sudo -u postgres pg_basebackup \
  -h PRIMARY_IP \
  -U replicator \
  -p 5432 \
  -D /var/lib/postgresql/15/main \
  -Fp \
  -Xs \
  -P \
  -R

What these flags mean:
- -Fp: plain format (copies files as-is, not a tar archive)
- -Xs: stream WAL during the backup so nothing is missed
- -P: show progress
- -R: write a standby.signal file and connection info automatically

You'll be prompted for the replicator password. The backup can take a few minutes depending on database size.

Step 5: Configure and start the standby

The -R flag in the previous step should have written the connection info into postgresql.auto.conf. Verify it:

sudo cat /var/lib/postgresql/15/main/postgresql.auto.conf

You should see something like:

primary_conninfo = 'host=PRIMARY_IP port=5432 user=replicator password=your-password'

Also confirm the standby signal file exists:

ls /var/lib/postgresql/15/main/standby.signal

If either is missing, create them manually. The standby won't replicate without standby.signal.

Start PostgreSQL on the standby:

sudo systemctl start postgresql

Step 6: Verify replication is working

On the primary, connect to PostgreSQL and check the replication status:

sudo -u postgres psql -c "SELECT client_addr, state, sent_lsn, write_lsn, replay_lsn, sync_state FROM pg_stat_replication;"

You should see one row with your standby's IP address and state = streaming. If this is empty, replication isn't connected - check the PostgreSQL logs on the standby first:

sudo tail -50 /var/log/postgresql/postgresql-15-main.log

On the standby, confirm it's in recovery mode:

sudo -u postgres psql -c "SELECT pg_is_in_recovery();"

This should return t (true). If it returns f, the standby thinks it's a primary, which means something went wrong.

Step 7: Test it

Create a test table on the primary:

sudo -u postgres psql -c "CREATE TABLE replication_test (id serial, val text, created_at timestamptz default now());"
sudo -u postgres psql -c "INSERT INTO replication_test (val) VALUES ('hello from primary');"

Check for it on the standby (you can query the standby directly, it's in read-only mode):

sudo -u postgres psql -c "SELECT * FROM replication_test;"

If you see the row, replication is working.

Common problems and fixes

Standby can't connect to primary
Check that port 5432 is open on the primary's firewall:
``bash
# On the primary
sudo ufw allow from STANDBY_IP to any port 5432
``

pghba.conf rejection errors in the log
The pg
hba.conf entry needs to match exactly. Check that the standby's IP matches what's in the file, and that you're using md5 not scram-sha-256 unless you've configured SCRAM on both ends.

Replication lag is climbing
Check walkeepsize on the primary - if the standby falls behind and the WAL is recycled before the standby can read it, replication will break. Increase walkeepsize or set up a replication slot (more advanced, covered in a future post).

Standby shows state = startup instead of streaming
The standby is still replaying the base backup or initial WAL. Give it a minute. If it stays in startup for more than a few minutes, check the standby's logs.

---

That's it. You now have a working streaming replication setup. The next things to learn from here are replication slots (which prevent the primary from recycling WAL the standby hasn't read yet), synchronous replication (where the primary waits for the standby to confirm writes before acknowledging them to the application), and how to actually perform a failover when you need to promote the standby. I'll cover those separately.

Found this useful?
☕ Buy Michael a Coffee
← More posts

Hey, I'm Michael Harlow.

Senior Systems Engineer · Boston, MA · Writing as sys.ghost

I have spent over a decade building and maintaining infrastructure at the intersection of technology and financial services. My career has taken me through three distinct sectors -- technology, private equity, and asset management -- and each one changed how I think about what reliable infrastructure actually requires.

I started in general IT, which is where most engineers who did not go straight into software end up. Data centers, networking, on-call rotations, learning to label cables properly because unlabeled cables are a promise that someone else will suffer later. The work taught me that almost every sophisticated system is, one layer down, a collection of unglamorous fundamentals that either hold or do not. I still believe that. I still label everything.

Private equity came next, and it was a different world. The infrastructure stakes there are less about uptime and more about data integrity. When deal teams are making acquisition decisions based on data you are responsible for, and when a due diligence process has a hard deadline that does not move regardless of what broke overnight, your relationship with reliability changes. A wrong number in an LP report does not cause an immediate incident. It causes a conversation in a partner meeting six weeks later, and by then you need to reconstruct what happened from imperfect records. I became obsessive about data provenance in PE and I have not stopped.

For the past several years I have been in asset management, supporting trading and investment operations infrastructure. This is the environment I find most technically interesting. The compliance requirements are demanding, the legacy systems have long institutional memories, and the tolerance for operational errors is genuinely low -- not just in terms of business impact, but in terms of regulatory consequence. When markets are open, there is no fixing it after the weekend.

I started Packet & Profit in January 2026 because I kept looking for the kind of writing I wanted to read and finding it mostly did not exist. There is a lot of content for engineers online. There is much less written by engineers working specifically inside regulated financial services firms, being honest about what that actually involves day to day. The compliance conversations, the legacy constraints, the incident management in front of stakeholders who measure downtime in dollars per minute. That is what I write about here.

Outside of work I have been running a Saturday morning robotics course at my local YMCA for kids aged 10 to 14. It is one of the better decisions I have made.

Certifications

Red Hat Certified Engineer (RHCE)
Certified Kubernetes Administrator (CKA)
AWS Solutions Architect -- Associate
CompTIA Security+
HashiCorp Vault Associate

My Stack

RHEL / Ubuntu
Kubernetes
OpenShift
Terraform
Ansible
Prometheus
Grafana
Python / Bash
AWS / Azure
Cisco / Palo Alto
PostgreSQL
Redis
HashiCorp Vault
Fluent Bit
Helm
ArgoCD

Career

2022 -- Present
Senior Systems Engineer, Asset Management -- Boston, MA
Leading infrastructure for trading operations and investment management systems. Responsibilities span network security, cloud migration strategy, Kubernetes platform engineering, and incident response. Deeply involved in T+1 settlement infrastructure work and the shift from overnight batch processing to near-real-time event-driven architecture.
2018 -- 2022
Systems Engineer, Private Equity -- Boston, MA
Built and maintained data infrastructure supporting deal teams, portfolio monitoring, and investor reporting. Managed infrastructure through multiple due diligence cycles with hard deadlines and high data integrity requirements. Led a major data platform migration from on-premises to cloud-hosted infrastructure, including security controls satisfying LP and regulatory requirements.
2015 -- 2018
Infrastructure Engineer, Retail Technology
Supported inventory management, real-time pricing, and supply chain integration systems across a high-SKU retail environment. Operated under peak load conditions where scale was a concrete engineering problem rather than an abstract one. Built out monitoring and alerting infrastructure from scratch and managed a full data center relocation.
2013 -- 2015
IT Engineer, Technology Sector
Established the professional fundamentals: data center operations, network infrastructure, endpoint management, and the on-call rotations that teach you more about system fragility than any textbook. Developed an appreciation for cable labeling that has never left me.

Get in Touch

If you are an engineer working in financial services, curious about the career path, or have a question about something I have written, I would genuinely like to hear from you. Use the and I will get back to you. If something here has been useful, a coffee is always appreciated.

A note on anonymity: I write under my own name but keep my current employer private. The financial services industry is small, the regulatory environment is real, and I want to write honestly without those constraints. All incidents and case studies on this site are anonymised. The technical content is real; identifying details are not.
Get in touch

Contact

Whether you are an engineer in financial services, have a question about something I have written, or just want to say hello - feel free to reach out. I read everything.

Powered by Resend · No spam, ever

Legal

Privacy Policy

Last updated: April 2026

This policy explains what information Packet & Profit collects when you visit this site, how it is used, and what choices you have.

Information We Collect

We do not require you to create an account or provide personal information to read this blog. The only personal information we collect is what you voluntarily submit through the contact form: your name, email address, and message. This information is transmitted via Resend and used solely to respond to your enquiry.

Google AdSense and Advertising

This site uses Google AdSense to display advertisements. Google AdSense uses cookies and similar tracking technologies to serve ads based on your prior visits to this and other websites. This means Google may use information about your visits to this site to show you personalised ads on other sites across the web.

You can opt out of personalised advertising by visiting Google Ads Settings, aboutads.info, or optout.networkadvertising.org. See Google advertising policies for more.

Cookies

This site uses a single first-party cookie to remember your theme preference (light or dark mode). This cookie contains no personal information. Third-party cookies may be set by Google AdSense for advertising purposes as described above.

Analytics

This site does not currently use any analytics platform beyond what Vercel provides as part of its standard hosting service (aggregated, anonymised traffic data).

Contact Form

When you submit the contact form, your name, email address, subject, and message are transmitted to the blog author via Resend. This data is not stored by this site and is not shared with any third party beyond Resend. See Resend's privacy policy for details.

Third-Party Links

Posts on this site may link to external websites. We are not responsible for the privacy practices or content of those sites.

Your Rights

If you have submitted a message via the contact form and would like that information removed, or if you have any questions about this policy, please use the contact form to get in touch.

Changes to This Policy

We may update this policy from time to time. The date at the top of this page reflects when it was last revised.

Legal

Terms of Service

Last updated: April 2026

By accessing and using Packet & Profit (packetandprofit.com), you agree to be bound by these Terms of Service. If you do not agree, please do not use this site.

Use of Content

All written content, illustrations, and code examples published on this site are the original work of Michael Harlow unless otherwise stated. You are welcome to share links to posts and quote brief excerpts (with attribution), but you may not reproduce full articles, copy content to other websites, or use the content for commercial purposes without written permission.

No Professional Advice

Content published on this site reflects personal opinions and professional experience. It is provided for informational and educational purposes only. Nothing on this site constitutes financial, investment, legal, or professional advice of any kind. See the for more detail.

Third-Party Links

This site may contain links to third-party websites. These links are provided for convenience and do not constitute an endorsement of the linked site or its content. We have no control over and accept no responsibility for external sites.

Advertising

This site participates in Google AdSense, which displays advertisements from third-party advertisers. The presence of an advertisement does not constitute an endorsement of the advertiser's products or services. Ad content is determined by Google based on the content of this site and your browsing history.

Accuracy of Information

While we make every effort to ensure the accuracy of information published on this site, technology and financial markets change rapidly. Information that was accurate at the time of publication may become outdated. We do not warrant the completeness, accuracy, or timeliness of any content on this site.

Limitation of Liability

To the fullest extent permitted by law, Packet & Profit and its author shall not be liable for any direct, indirect, incidental, or consequential damages arising from your use of, or inability to use, this site or its content.

Changes to These Terms

We reserve the right to update these terms at any time. Continued use of the site following any changes constitutes your acceptance of the revised terms. The date at the top of this page reflects the most recent revision.

Contact

If you have questions about these terms, please use the .

Legal

Disclaimer

Last updated: April 2026

Packet & Profit is a personal blog written by Michael Harlow, a Systems Engineer based in Boston, MA. The views expressed here are entirely his own and do not represent those of any employer, client, or organisation he is affiliated with.

Not Financial or Investment Advice

This site discusses financial services technology, investment management infrastructure, and related engineering topics from a technical practitioner's perspective. Nothing published here is financial advice, investment advice, or a recommendation to buy, sell, or hold any security, asset, or financial instrument. The author is not a registered financial adviser, broker, or investment professional.

Content that references financial markets, trading systems, or investment firms is provided for technical and educational context only. Any figures, case studies, or examples are illustrative and should not be relied upon for financial decisions.

Not Legal or Professional Advice

Nothing on this site constitutes legal, compliance, regulatory, or professional advice. Readers should consult qualified professionals for advice specific to their circumstances.

Professional Experience

Posts on this site draw on the author's professional experience in systems engineering across private equity, retail technology, and asset management. Specific details about employers, clients, projects, and colleagues have been anonymised or generalised. Any resemblance to specific organisations is incidental.

Accuracy

The author makes reasonable efforts to ensure published information is accurate at the time of writing. The technology and financial services landscape changes quickly. Readers should verify any technical or regulatory information against current primary sources before acting on it.

Affiliate Links and Advertising

This site displays advertisements through Google AdSense. The site may also contain links to tools, services, or products that the author uses or finds useful. These are not paid endorsements unless explicitly stated. The author's opinions are his own and are not influenced by advertisers.

Questions

For questions about anything on this site, please use the .

This site uses cookies for theme preferences and displays ads via Google AdSense, which may use cookies to personalise ads.