Skip to content

Feature/9086 task offload sites parquetduckdb refresh to aws batch to reduce api service memory usage - #275

Merged
utas-raymondng merged 21 commits into
mainfrom
feature/9086-task-offload-sites-parquetduckdb-refresh-to-aws-batch-to-reduce-api-service-memory-usage
Sep 8, 2026
Merged

Feature/9086 task offload sites parquetduckdb refresh to aws batch to reduce api service memory usage#275
utas-raymondng merged 21 commits into
mainfrom
feature/9086-task-offload-sites-parquetduckdb-refresh-to-aws-batch-to-reduce-api-service-memory-usage

Conversation

@leslieduan

@leslieduan leslieduan commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Offload the heavy Parquet DuckDB load for mooring/wave-buoy sites data from the this project to batch job, so the service only does a cheap reload from an S3 snapshot instead of the full heavy read.

@utas-raymondng utas-raymondng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please kindly review comments

Comment thread data_access_service/config/config-edge.yaml Outdated
Comment thread data_access_service/config/config.py Outdated
Comment thread data_access_service/config/config.py Outdated
Comment thread data_access_service/core/scheduler.py
id="refresh_task",
name="Repository data refresh task",
self._reload_task,
trigger=CronTrigger(hour="*/2", minute="0"), # Every 2 hours, on the hour

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the job of the batch scheduler rather than this app ?

Comment thread data_access_service/core/scheduler.py
f"""
CREATE OR REPLACE TABLE {quote_ident(self.table)} AS
SELECT * FROM read_parquet('{self.backup_dataset}')
SELECT * FROM read_parquet('{self.snapshot_dataset}')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should do

db.execute("INSTALL httpfs; LOAD httpfs;") 

in your duckdb client init if you want to read s3 fast.

Also please use, duckdb can use a few optimization method internally to speed up the query

f"""
CREATE OR REPLACE VIEW {quote_ident(self.table)} AS
SELECT * FROM read_parquet('{self.snapshot_dataset}')
"""

in case the speed is not fast enough with single file parquet you should consider using partition hive and generate the parquet with time partition

@utas-raymondng utas-raymondng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are few minor things that needs to address with another PR

Comment thread data_access_service/core/scheduler.py
table = "test_mooring"
bucket = "test-bucket"
backup_bucket = "test-backup"
snapshot_bucket = "test-snapshot"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is test only setting you should put it in config-dev.yaml or config-test.yaml

@utas-raymondng
utas-raymondng merged commit b8d8874 into main Sep 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants