Maritime · 6 min read

Vessel Data Pipeline Optimization

I redesigned the Python job that loads a tanker fleet's voyage reports, cutting its runtime by 40% and stopping reports from going missing.

  • Python
  • MSSQL
  • C#/.NET
  • Angular

Context

The data behind a fleet's performance

Each tanker in the fleet reports on its voyage as it happens: a noon report each day at sea, a departure report when it leaves port, an arrival report when it reaches port, and a bunker report when it takes on fuel. Crews fill them in as offline XML forms in the fleet's voyage reporting platform, and the forms sync to shore when the ship has a connection.

On shore, a Python ingestion job loads the reports into MSSQL, and the vessel performance team reviews them on a dashboard to track fuel use, speed and voyage efficiency. Everything the team knows about how the fleet is performing starts with this pipeline.

Each vessel sends noon, arrival, departure and bunker reports as XML forms up to the fleet's reporting platform. A scheduled Python ingestion job retrieves the reports for the whole fleet in one API request and saves them to the database. The same job runs 14 checks on the voyage data and saves any issues it flags. The dashboard reads the reports and their issues through an API and shows them to the vessel performance team.

The problem

Missing reports and unreliable data

The business was facing two problems:

  • Reports were going missing. The ingestion job ran every 8 hours, but a single run could take longer than that: one measured run needed about 8 hours for fewer than 200 reports. When a run overran, the next one was skipped, and when a run stopped partway, the next one started from the wrong point. Reports in that gap were never loaded, and nothing flagged it.
  • Bad data went unnoticed. Reports are typed by hand at sea, so event times, distances, fuel and cargo figures don't always add up. The team could only catch those errors by checking reports manually.

The performance team was making decisions from data that was both incomplete and unchecked.

Root cause

How the old job worked

I traced each run from the API request to the database write. No single query was slow; the job repeated work at every step of a loop it ran once per active vessel:

  1. Query that vessel's latest report time. The wrong starting point: runs began from the latest report time, not from when reports were last submitted, so every run re-fetched and re-saved reports it already had.
  2. Request that vessel's reports from the reporting platform. One request per vessel, sent one after another on every run, falling back to a fixed look-back window when no date was found.
  3. Write each report to a temporary XML file and read it back. Extra disk work for every single report.
  4. Look up the vessel again, then parse and save. Database lookups for data that doesn't change during a run.

Faster hardware wouldn't fix that. The job had to do less work and know exactly where to resume.

Comparison

Old vs new logic, side by side

Here's what that looks like in practice, and what the fix changed. Press play to run both versions on the same reports, including an interrupted run.

Old logic

a loop per vessel

PlatformIngestion jobDatabaserequestquerysave
Requests
0
Saved
0/0
Repeated
0
Missed
0
Time
0.0 s

Ready

New logic

one request for the fleet

PlatformIngestion jobDatabaserequeststart datesave
Requests
0
Saved
0/0
Overlap
0
Missed
0
Time
0.0 s

Ready

  • Report saved
  • Request or query
  • Repeated or overlap
  • Interrupted
  • Missed

Each tile is one step of the run, filled in the order it happened. This is an illustrative example with 6 vessels and 24 new reports. Both versions are interrupted at the same point, and the new one takes 40% less time, matching the measured result.

The fix

One fleet-wide request and automated checks

I designed the new logic, walked stakeholders through it with before-and-after flow charts, and implemented it.

  • One request for the whole fleet, starting from the latest stored resubmission date. That date is now stored with each report, including existing ones.
  • Vessels loaded once per run and matched by IMO number. If a vessel's name changes, its IMO number stays the same, so the team is alerted to update the vessel record instead of reports being loaded against outdated details.
  • Built to recover: oldest-first processing with a small overlap, resubmitted reports updated in place, a failed save or check emailed to the team while the run moves on, and a summary after every run.
  • 14 automated voyage-data checks, built with the vessel performance team and run as each report is saved.
    What the 14 checks catch
    AreaWhat the checks catch
    Event timingMissing, out-of-order or overlapping events
    Distance and speedDistances and speeds that don't add up
    Engine hoursEngine hours that don't match time at sea
    FuelFuel figures that don't reconcile
    CargoCargo changes with no matching port event
    Voyage continuityGaps between one voyage leg and the next

    Which checks apply depends on the report type and whether the vessel is at sea or in port.

  • Issues shown on the dashboard: I added each report's flagged issues to the existing C#/.NET API response and built an errors view into the report view of the Angular dashboard, so the team sees them alongside the report.

Testing

How it was tested

  • Controlled benchmark

    Side by side on identical data

    The old and new jobs ran against separate copies of the database with the same date window.

    40% lower runtime

  • Release

    QA, then user acceptance testing

    Accepted against agreed criteria: no duplicate updates, no stalled runs, and every downstream feature still working.

    Accepted for production

  • Validation checks

    Tested live with the performance team

    After release, each check was run against real reports until the flagged issues matched what the team expected.

    14 checks verified

  • Production

    Backlog cleared in batches

    The backlog came back from the reporting platform in batches, so it was cleared over four runs, each resuming exactly where the last one stopped.

    800+ reports, no gaps

Results

40% faster, with no missed reports

  • 40% lower runtime in a controlled benchmark: same data, same date window. This is the headline figure.
  • In production, about 2.5 minutes per report before and 20–60 seconds after. These runs used different data, so they show the trend rather than a controlled comparison; every new run finished well inside the 8-hour window.
  • A backlog of 800+ reports cleared in four runs, each run resuming where the last one stopped; once caught up, runs with no new reports took about 5 seconds.
  • No more silent gaps: an interrupted run now resumes from the last stored report.
  • 14 automated checks flag inconsistent voyage data on the dashboard instead of leaving it to manual review.

Looking back

What I'd do better

  • Platform

    Move ingestion to serverless functions

    Running the pipeline as serverless functions instead of a scheduled Python job would give built-in run logs and alerts, rather than relying on emails from a script.

  • Self-service

    On-demand re-ingestion

    A simple UI to re-run ingestion on demand: pick one or more vessels by IMO number and a date range, and load that exact set of reports again, including older vessels and historical data.

  • Visibility

    One place to track every run

    A run history showing each run, what it loaded, what it skipped and any errors, so the team can check the pipeline themselves without needing a developer.

  • Code

    Leaner parsing and database access

    Parse each report's XML directly instead of writing it to a temporary file first, a step the fix left in place, and use parameterised queries with batched writes to cut the remaining per-report database calls.

Contact