AWS Builder Center
[EN] ChDB or DuckDB on AWS Lambda: A Technical Comparison — #2 Benchmark Performance of Data Replication in a Data Lake

[EN] ChDB or DuckDB on AWS Lambda: A Technical Comparison — #2 Benchmark Performance of Data Replication in a Data Lake

Building and running DuckDB and ChDB processes inside AWS Lambda across several common data replication use cases within a data lake, a classic data ingestion pattern, all to make a performance-based technical comparison

AWS UG Arequipa Leader | AWS Community Builder - Data | AWS X4 | Data Engineer
We have already seen that  DuckDB is the best option for AWS Lambda when it comes to creating code development environments for data pipelines , compared with ChDB. This is an important point to consider. However, we cannot base the entire process of building data pipelines on this alone; there is a much more decisive technical factor to consider: performance.
So the question that always comes up when evaluating a solution is:
🤔💭 Which performs better on AWS Lambda: DuckDB or ChDB?
This is a complicated question because there are several considerations within a data architecture that must be taken into account. Some of the most important ones are:
  • Database size; whether it is a few MB or several GB.
  • Operations to be performed; because performing a  GROUP BY  is different from having a simple  SELECT + WHERE  as the core of the transformation.
  • Data platform to interact with; whether the data is in a database or a data lake, where it must be stored or retrieved.
  • Data organization; whether they are partitioned and whether they have any form of indexing or operational optimization.
  • Data format; in the case of a data lake, because performance may differ depending on whether you work with JSON, Apache Parquet, or Apache Iceberg. A similar consideration for databases involves columns and the JSON format.
Since these are specific details of each business use case for data engineers, and every business has unique characteristics, summarizing all business cases is impossible. So, let's start with something more basic and specific within data engineering:
✨ Performance of data replication within a data lake ✨
This activity can take several unique and interesting forms. Some examples include:
  • Making data available in a suitable format from a staging layer for transformation activities in a data pipeline.
  • Delivering data in a specific format within final storage for consumers.
Because this main concept can represent several "common" use cases, each with its own unique details, we need a reference guide. The most important value of this reference guide is identifying general performance patterns across different scenarios so that informed decisions can be made. The specific details of each scenario will serve as a reference for particular aspects you may want to consider when using it.



Let's define the baseline for the scenarios

As the saying goes, "the devil is in the details": understanding all the details of a subject allows us to understand it correctly. The same applies to technical scenarios used to evaluate a solution.
The following is a list of the technical aspects we will examine in the evaluation scenarios:
Detalle
Valor
Data format
Apache Parquet, Apache Iceberg, CSV, and JSON
Data source
The "Yellow Taxi Trip" section of NYC Taxi Trips Record Data.
Data volume
61MB, 117MB, 368MB, 484MB, 733MB, 807MB, 941MB, 1279MB, and 1940MB
Runtime
Python 3.13
Comparison engine
DuckDB 1.4.5 and ChDB 4.3.0
Processing architecture
x86_64
Does it evaluate the engine's initial setup performance?
Yes
Does it evaluate extension-loading performance?
Yes
Does it evaluate memory usage?
Yes, according to what AWS Lambda reports.
Temporary memory usage?
DuckDB and ChDB will use 70% of RAM, but this may change
Now we need to define the baseline for the data replication scenarios, which means specifying the data format for both the source and the destination:
  1. Apache Parquet → Apache Parquet
  1. Apache Parquet → JSON
  1. Apache Parquet → CSV
  1. Apache Parquet → Apache Iceberg
The specified data volumes were created from the source dataset as follows.
Data volume
Dates selected from the source dataset
Volume category
61MB
January 2026
Low
117MB
January to February 2026
Low
368MB
January to March 2026, and May to July 2026
Low
484MB
January to March 2026, May to July 2026, and January to March 2025
Low
733MB
January to April 2025, and January to August 2026
Medium
807MB
January to May 2025, and January to August 2026
Medium
941MB
January to July 2025, and January to August 2026
Medium
1279MB
All of 2025 and January to August 2026
High
1940MB
All of 2025 and 2024, and January to August 2026
High
With all these details and the structure for each scenario in place, the key question is:
🤔💭 What can we learn from these scenarios?



A general review first

Using the DuckDB engine

With the data movement scenarios clarified, the following code was created to run them with JSON, Apache Parquet, and CSV as the destination data formats.
import time
import duckdb
import os
import shutil
import json

#####################
## utility función
#####################

def log_metric(metric, value, **dimensions):
print(json.dumps({
"type": "BENCHMARK",
"metric": metric,
"value": value,
**dimensions
}))

def lambda_handler(event, context):
# Variables
TABLE_ORIGIN = event.get("TABLE_ORIGIN")
TABLE_DESTINY = event.get("TABLE_DESTINY")
MEMORY_LIMIT_MB = event.get("MEMORY_LIMIT_MB")
FILE_SIZE_BYTES = event.get("FILE_SIZE_BYTES")
PROCESS_EVENT = event.get("PROCESS_EVENT")
DESTINY_FORMAT = event.get("DESTINY_FORMAT")
DIMS = {"event_process": PROCESS_EVENT}

# Preparing workspace
start = time.time()
os.makedirs("/tmp/duckdb_tmp", exist_ok=True)
print(duckdb.__version__)

con = duckdb.connect(database=':memory:')
con.execute(f"SET memory_limit = '{MEMORY_LIMIT_MB}MB';") ## Limite de memoria
con.execute("SET temp_directory='/tmp/duckdb_tmp';") ## Direccion dde
con.execute("SET threads = 1;")
con.execute("SET preserve_insertion_order = false")
end_setup = time.time()
log_metric("setup_time", end_setup - start, event_process = PROCESS_EVENT)

# Loading extension
EXTENSIONS_DIR = "/opt/duckdb/extensions"
con.execute(f"SET extension_directory = '{EXTENSIONS_DIR}'")

con.execute("LOAD httpfs")
con.execute("LOAD parquet")

end_loading_extension = time.time()
log_metric("loading_extension", end_loading_extension - end_setup, event_process = PROCESS_EVENT)

# Processing core
query = f"""
COPY (
SELECT *
FROM read_parquet('<SOURCE_TABLE_PATH_IN_S3>/*.parquet')
)
TO '<TARGET_TABLE_PATH_IN_S3>/{DESTINY_FORMAT}/{TABLE_DESTINY}'
(
FORMAT {DESTINY_FORMAT},
FILE_SIZE_BYTES '{FILE_SIZE_BYTES}MB',
OVERWRITE_OR_IGNORE
);
"""
result = con.execute(query)
end_execution = time.time()
log_metric("query_execution", end_execution - end_loading_extension, event_process = PROCESS_EVENT)
con.close()
# Clean temporal space

con.close()
if os.path.exists("/tmp/duckdb_tmp"):
shutil.rmtree("/tmp/duckdb_tmp", ignore_errors=True)
end_cleaning = time.time()
log_metric("cleaning_execution", end_cleaning - end_execution, event_process = PROCESS_EVENT)

return {
"statusCode": 200
}

For Apache Iceberg as the destination data format, the code was changed because it requires additional extensions and configuration to work in this case. Keep in mind that the table is created in S3 Tables.
import time
import duckdb
import os
import shutil
import json

#####################
## utility función
#####################

def log_metric(metric, value, **dimensions):
print(json.dumps({
"type": "BENCHMARK",
"metric": metric,
"value": value,
**dimensions
}))

def lambda_handler(event, context):
# Variables
TABLE_ORIGIN = event.get("TABLE_ORIGIN")
TABLE_DESTINY = event.get("TABLE_DESTINY")
MEMORY_LIMIT_MB = event.get("MEMORY_LIMIT_MB")
PROCESS_EVENT = event.get("PROCESS_EVENT")
DIMS = {"event_process": PROCESS_EVENT}

# Preparing workspace
start = time.time()
os.makedirs("/tmp/duckdb_tmp", exist_ok=True)
print(duckdb.__version__)

con = duckdb.connect(database=':memory:')
con.execute(f"SET memory_limit = '{MEMORY_LIMIT_MB}MB';") ## Limite de memoria
con.execute("SET temp_directory='/tmp/duckdb_tmp';") ## Direccion dde
con.execute("SET home_directory='/tmp';")
con.execute("SET threads = 1;")
con.execute("SET preserve_insertion_order = false")
end_setup = time.time()
log_metric("setup_time", end_setup - start, event_process = PROCESS_EVENT)

# Loading extension
EXTENSIONS_DIR = "/opt/duckdb/extensions"
con.execute(f"SET extension_directory = '{EXTENSIONS_DIR}'")
con.execute("LOAD aws")
con.execute("LOAD httpfs")
con.execute("LOAD parquet")
con.execute("LOAD avro")
con.execute("LOAD iceberg")

con.execute("""
CREATE SECRET (
TYPE s3,
PROVIDER credential_chain
)
""")

con.execute(f"""
ATTACH '<ARN_S3_TABLE_BUCKET>'
AS s3_catalog (
TYPE iceberg,
ENDPOINT_TYPE s3_tables
)
""")

end_loading_extension = time.time()
log_metric("loading_extension", end_loading_extension - end_setup, event_process = PROCESS_EVENT)

# Processing core
query = f"""
CREATE TABLE s3_catalog.<S3_NAMESPACE>.{TABLE_DESTINY} AS
SELECT *
FROM read_parquet(
'<SOURCE_TABLE_IN_S3>/{TABLE_ORIGIN}/*.parquet',
union_by_name = true
)
"""
result = con.execute(query)
end_execution = time.time()
log_metric("query_execution", end_execution - end_loading_extension, event_process = PROCESS_EVENT)
con.close()
# Clean temporal space
if os.path.exists("/tmp/duckdb_tmp"):
shutil.rmtree("/tmp/duckdb_tmp", ignore_errors=True)
end_cleaning = time.time()
log_metric("cleaning_execution", end_cleaning - end_execution, event_process = PROCESS_EVENT)
return {
"statusCode": 200
}
An important detail here is that an AWS Lambda Layer was used to make all the required extensions available to the AWS Lambda function.

It is also worth clarifying that, for all exercises, the documented mechanisms for performing each write operation were used. Although each mechanism has configuration options that can improve the operation, this article describes how they were configured to generate the values for this comparison. In this experiment, for CSV, JSON, and Apache Parquet destination formats, I had to use  FILE_SIZE_BYTES  to control AWS Lambda memory usage and avoid Out-of-Memory errors, which occurred several times.

However, with Apache Iceberg, the code used did not encounter an Out-Of-Memory problem.

DuckDB query performance in low-data-volume scenarios, using different AWS Lambda RAM configurations, is shown below. The values are averages calculated from sequences of 10 consecutive executions for each scenario.

There are several points we can begin to derive from the chart:
✨ Better performance with Parquet and Iceberg than with CSV and JSON, Since CSV and JSON require an explicit conversion process, it is expected that they will take additional time.
🔥 The more RAM AWS Lambda has, the shorter the execution time in general, because more memory is available for the operations being performed. This helps avoid Time-Out errors and makes the function more stable.
⚠️ The Time-Out in JSON was unexpected which is why some points are not shown in the chart. This demonstrates that every format has different performance characteristics, and proof-of-concept testing is essential to determine whether an option is viable.
🚨 The larger the data volume, the longer the operation will take to complete the operation. Therefore, care must be taken to avoid Time-Out errors. The data volume to be processed becomes a parameter to evaluate when determining the technical limit of using AWS Lambda for that operation.
❓ An interesting file-size management mechanism, because I can approximate output file sizes using the  FILE_SIZE_BYTES  parameter. The tests used 10 MB for the chart. In my tests, if I did not change this setting, it attempted to create a single file, which affected the AWS Lambda process and caused an Out-Of-Memory error.

To complement the performance chart, the following chart shows the memory usage reported by AWS Lambda with DuckDB for each scenario.

We can draw the following additional conclusions:
🔥 More RAM means greater stability across executions. This helps avoid Out-Of-Memory problems because overall RAM consumption is lower.
💡 Metrics should be considered and analyzed across value ranges, because as data volume increases, memory usage also increases, eventually causing some executions to fail with Out-Of-Memory. The key is to identify the data volumes at which this error occurs when assessing the solution's resilience and viability.
⚠️ The data format affects memory usage so we must carefully consider both cost and solution viability. Each format has different consumption and growth behavior depending on the data volume being processed and the available RAM.

In addition to this, there are other relevant points to consider.
⏱ The components that affected DuckDB performance on AWS Lambda are ranked below according to my assessment of the experiments. Keep in mind that these are reference values.
Area
% of total runtime
Additional comments
Main query
85% al 98%
Most of the time is spent here.
Extension loading
14% al 1%
It appears to become faster when more RAM is available.
DuckDB initialization
0.7% al 0.6%
It appears to become faster when more RAM is available.
AWS Lambda initialization
0.3% al 0.4%
This is a value that eventually disappears.
The average extension-loading time was 3.582 seconds, while AWS Lambda initialization took 0.438 seconds. Interestingly, extension-loading time appears likely to decrease as the RAM allocated to AWS Lambda increases.

⚖️ There is a speed-versus-memory trade-off with a catch I observed this when changing the  FILE_SIZE_BYTES  parameter for the CSV, Apache Parquet, and JSON scenarios. It creates a trade-off: changing how RAM is used by the operations can increase the probability of an Out-Of-Memory error while reducing the probability of a Time-Out error during AWS Lambda execution. The following table shows the Apache Parquet case across several data volumes with a 256 MB RAM configuration.

Revisión
61MB
117MB
368MB
484MB
10MB
Performance
24.96 seg
46.27 seg
141.36 seg
192.96 seg
10MB
Memory
92.05%
94.63%
94.99%
96.17%
20MB
Performance
24.55 seg
45.84 seg
144.22 seg
191.27 seg
20MB
Memory
95.31%
98.29%
98.08%
97.93%
30MB
Performance
24.27 seg
47.48 seg
145.49 seg
OOM
30MB
Memory
96.67%
~100%
~100%
+100%
The catch with this trade-off is that it often helps, but sometimes it has no effect, as shown by the italicized values. In my opinion, this is because so little RAM is available that the benefit is not enough to compensate, while the probability of an Out-Of-Memory error increases.

Using the ChDB engine

For ChDB, I had to make several modifications and experiment with different strategies to find a suitable implementation for the comparison. This was because it consumed more RAM than expected in certain scenarios, requiring additional configurations and basic resource management strategies to control the process.
For scenarios targeting JSON, CSV, and Apache Parquet data formats, this was the code.
import chdb
import logging
import os
import time
import json
import shutil

logger = logging.getLogger()
logger.setLevel(logging.INFO)

def log_metric(metric, value, **dimensions):
print(json.dumps({
"type": "BENCHMARK",
"metric": metric,
"value": value,
**dimensions
}))

def lambda_handler(event, context):
PROCESS_EVENT = event.get("PROCESS_EVENT")

start = time.time()

### Preparing workspace
DB_PATH = "/tmp/chdb_database"
os.makedirs(DB_PATH, exist_ok=True)

CONN = chdb.connect(DB_PATH)
end_setup = time.time()
log_metric("setup_time", end_setup - start, event_process = PROCESS_EVENT)

source = event["TABLE_ORIGIN"]
target = event["TABLE_DESTINY"]
output_format_sql = event["OUTPUT_FORMAT"]

memory_mb = int(event.get("MEMORY_LIMIT_MB", 256))
memory_bytes = memory_mb * 1024 * 1024
### Processing core
sql = f"""
INSERT INTO FUNCTION s3(
'{target}',
'{output_format_sql}'
)
SELECT *
FROM s3('{source}', 'Parquet')
SETTINGS
max_memory_usage = {memory_bytes},
max_threads = 1,
max_insert_threads = 1,
max_block_size = 8192,
s3_truncate_on_insert = 1
"""

CONN.query(sql)
end_execution = time.time()
log_metric("query_execution", end_execution - end_setup, event_process = PROCESS_EVENT)
CONN.close()
### Cleaning workspace
if os.path.exists("/tmp/duckdb_tmp"):
shutil.rmtree("/tmp/duckdb_tmp", ignore_errors=True)
return {
"status": "SUCCESS",
"target": target
}

For scenarios targeting Apache Iceberg, the code was different and integrated with an S3 bucket because it requires an explicit location for the data, something that S3 Tables does not specify. The table schema also had to be specified and the table created so it could be built natively, without depending on additional tools for the process.
import chdb
import logging
import json
import time
from urllib.parse import urlparse

logger = logging.getLogger()
logger.setLevel(logging.INFO)

def log_metric(metric, value, **dimensions):
print(json.dumps({
"type": "BENCHMARK",
"metric": metric,
"value": value,
**dimensions
}))

def sql_literal(value):
return "'" + str(value).replace("\\", "\\\\").replace("'", "\\'") + "'"

def quote_identifier(name):
return "`" + name.replace("`", "``") + "`"

def lambda_handler(event, context):
start = time.time()

source = event["TABLE_ORIGIN"]
target = event["TABLE_DESTINY"]
process = event.get("PROCESS_EVENT", "UNKNOWN")
memory_mb = int(event.get("MEMORY_LIMIT_MB", 256))

if memory_mb <= 0:
raise ValueError("MEMORY_LIMIT_MB debe ser mayor que cero.")

# Interpretar el destino s3://bucket/prefix/tabla
parsed = urlparse(target)

if parsed.scheme != "s3" or not parsed.netloc or not parsed.path.strip("/"):
raise ValueError(
"TABLE_DESTINY debe tener el formato s3://bucket/prefix/tabla"
)

bucket = parsed.netloc
table_path = parsed.path.strip("/")
table_name = table_path.split("/")[-1]

region = event.get("REGION", "us-east-1")

iceberg_url = (
f"https://{bucket}.s3.{region}.amazonaws.com/"
f"{table_path}/"
)

memory_bytes = memory_mb * 1024 * 1024
table = quote_identifier(table_name)

# Esquema de yellow_tripdata
schema = [
("VendorID", "Nullable(Int32)"),
("tpep_pickup_datetime", "Nullable(DateTime64(6, 'UTC'))"),
("tpep_dropoff_datetime", "Nullable(DateTime64(6, 'UTC'))"),
("passenger_count", "Nullable(Int64)"),
("trip_distance", "Nullable(Float64)"),
("RatecodeID", "Nullable(Int64)"),
("store_and_fwd_flag", "Nullable(String)"),
("PULocationID", "Nullable(Int32)"),
("DOLocationID", "Nullable(Int32)"),
("payment_type", "Nullable(Int64)"),
("fare_amount", "Nullable(Float64)"),
("extra", "Nullable(Float64)"),
("mta_tax", "Nullable(Float64)"),
("tip_amount", "Nullable(Float64)"),
("tolls_amount", "Nullable(Float64)"),
("improvement_surcharge", "Nullable(Float64)"),
("total_amount", "Nullable(Float64)"),
("congestion_surcharge", "Nullable(Float64)"),
("Airport_fee", "Nullable(Float64)"),
("cbd_congestion_fee", "Nullable(Float64)")
]

columns = ", ".join(quote_identifier(name) for name, _ in schema)
definitions = ", ".join(
f"{quote_identifier(name)} {dtype}" for name, dtype in schema
)

conn = chdb.connect()

logger.info("ChDB version: %s", chdb.__version__)
logger.info("Origen: %s", source)
logger.info("Destino Iceberg: %s", iceberg_url)

conn.query("SET allow_insert_into_iceberg = 1")

conn.query(f"""
CREATE TABLE IF NOT EXISTS {table}
({definitions})
ENGINE = IcebergS3({sql_literal(iceberg_url)})
""")
setup_end = time.time()

log_metric(
"setup_time",
setup_end - start,
event_process=process
)

# Processing core
sql = f"""
INSERT INTO {table} ({columns})
SELECT {columns}
FROM s3({sql_literal(source)}, 'Parquet')
SETTINGS
max_memory_usage = {memory_bytes},
max_threads = 1,
max_insert_threads = 1,
max_block_size = 8192
"""

conn.query(sql)
execution_end = time.time()

log_metric(
"query_execution",
execution_end - setup_end,
event_process=process
)
conn.close()

return {
"status": "SUCCESS"

}


ChDB query performance in low-data-volume scenarios, using different AWS Lambda RAM configurations, is shown below. The values are averages calculated from sequences of 10 consecutive executions for each scenario.

We can draw the following additional conclusions:
💡 More RAM generally means better performance as with DuckDB. Each data format has different processing times, as explained in the DuckDB section, and data volume also affects execution performance. There is a RAM threshold beyond which allocating more memory to AWS Lambda has little performance benefit. This can be seen in the 1,536 MB and 2,048 MB RAM scenarios with 61 MB of data, where the improvement was only 0.65 seconds. DuckDB is not exempt from this behavior.
🔥 It performs better with some data formats; Since the RAM allocations were different, the results were not directly comparable with DuckDB. I therefore ran a test using the same RAM allocation for DuckDB in the JSON and Apache Parquet scenarios. The following were the performance and RAM results.



This shows that, with the same AWS Lambda RAM configuration, ChDB performs better in the JSON scenario than in Apache Parquet. This suggests that it may be a more suitable option for non-analytical formats and should therefore be considered for a proof of concept.
‼️ There is no control over the size of the files created; You can generally partition files using the  PARTITION BY...  command, but this does not guarantee that the generated files will have the same size, as you can approximate with DuckDB. Since ChDB creates a single file, I continued with that approach because it did not cause a problem. The only exception was Apache Iceberg, which generated several files between 17 MB and 18 MB in the test.
🤔 The process memory mode matters; if you look at the Apache Iceberg code, it uses RAM, while the other cases use AWS Lambda disk. This was done because JSON, CSV, and Apache Parquet consumed a lot of RAM, and moving the process to disk helped optimize it. For Apache Iceberg, however, I had to use RAM because using disk repeatedly caused Memory-Limit-Exceeded errors. Choosing the type of memory to use may therefore help with intermediate operations within the process.

To complement the main performance chart, the following chart shows the memory usage reported by AWS Lambda with ChDB for each scenario.

Together with the additional comparison chart against DuckDB, we can draw the following conclusions:
💡 Similar behavior to DuckDB in several respects for example, each data format has a different consumption profile, and more RAM makes the AWS Lambda process more stable, up to the point where additional RAM no longer improves performance.
😮 The minimum RAM required depends on the data format; because some data formats require less memory than others to run on AWS Lambda. This is something to review and investigate in your proof of concept. The charts provide an indication for the most popular data formats.
🤯 Process memory management must also be reviewed; porque A common error I encountered was Memory-Limit-Exceeded. In fact, it occurred frequently with AWS Lambda configured with 756 MB of RAM. I learned two important things from this:
  1. It may work if you experiment with the code's  memory_bytes  parameter to achieve viable executions. Review the workload, including the number of executions, to determine whether this is a problem.
  1. If it is still not viable, you must allocate more RAM to Lambda.
🤔 The process memory mode also matters for execution, because configuring the process to use disk or RAM can affect the likelihood of an Out-Of-Memory or Memory-Limit-Exceeded failure. This is worth reviewing and investigating in your proof of concept.
😋 It is more aggressive in its RAM consumption which may cause Out-Of-Memory errors even with small data volumes. This is an important point to consider when making design decisions and conducting proof-of-concept tests.

In addition to this, there are other relevant points to consider.
⏱ The components that affected ChDB performance on AWS Lambda are ranked below according to my assessment of the experiments. Keep in mind that these are reference values.
Area
% of total runtime
Additional comments
Main query
96% al 99%
Most of the time is spent here.
ChDB initialization
1.2% al 0.2%
This is a fixed component, and it may vary depending on the case.
AWS Lambda initialization
2.8% al 0.8%
This is a value that eventually disappears.
The average AWS Lambda initialization time was 1.692 seconds, showing that the container image approach does affect AWS Lambda instance performance during cold starts.
🤔 A trade-off between more RAM and speed—misleading gains because there is evidence that increasing the  memory_bytes  parameter improves performance in several scenarios, but not as much in others. I think this is due to the nature of the test: I observed more unusual values than with DuckDB, and RAM consumption did not approach 100% of the available memory reported by AWS Lambda.



What about medium or large data volumes?

Since larger data volumes may require more RAM in AWS Lambda, these tests help validate whether the points discussed above still hold. When DuckDB was tested in these scenarios, the following performance and memory-consumption charts were obtained.



This validates the key points observed earlier:
1️⃣ The ranking of RAM efficiency, from most efficient to least efficient, is as follows: Apache Parquet, Apache Iceberg, CSV, and JSON. This shows that each data format has its own memory-consumption behavior and minimum RAM requirement.
2️⃣ The amount of RAM directly affects execution performance; up to a limit that you need to evaluate. The data volume to be processed, according to the data format, also affects execution stability at the level required by the workload by helping avoid potential Out-Of-Memory and/or Time-Out failures.
An important observation for this engine is that having more RAM allows you to explore a wider range of  FILE_SIZE_BYTES  values to find a balance between performance, output file size, and AWS Lambda RAM consumption.
For ChDB in these scenarios, the following charts summarize the results.


This reveals some interesting new points and confirms others:
1️⃣ There is a minimum RAM requirement in AWS Lambda. A common error in these scenarios was Memory-Limit-Exceeded at the beginning. Managing how much RAM you can allocate to AWS Lambda, together with adjusting how much RAM the engine can use for an operation, are critical considerations that affect cost and the stability and number of executions you can run.
2️⃣ Better performance and stability than DuckDB with non-analytical formats. It achieves viable execution and performance in several scenarios for JSON and CSV data formats, compared with Apache Iceberg and Apache Parquet. This chart summarizes the comparison of both engines using Apache Iceberg and JSON.



3️⃣ It appears to exhibit more stable RAM consumption overall compared to DuckDB.
An important observation for this engine is that having more RAM allows you to explore a wider range of  memory_bytes  values to find a balance between performance, output file size, and AWS Lambda RAM consumption.



Conclusions and recommendations

With all these observations and charts, we can now answer the question "Which performs better on AWS Lambda: DuckDB or ChDB?"; and the answer is: 🫣 it depends.
The answer is based on the fact that a different engine stands out in each scenario, based on my assessment of this experiment. It depends on how the performance requirements and use case align with the patterns observed in the tests. The patterns I identified are as follows:
  • For replicating data from Apache Parquet to JSON/CSV with medium or large data volumes and high performance requirements, ChDB is the suitable option. For small data volumes and lower performance requirements, DuckDB is worth considering.
  • For replicating data from Apache Parquet to Apache Parquet/Iceberg, DuckDB is my default choice.
In addition to these patterns, there are other relevant technical points worth considering:
📝 The main challenges of using DuckDB/ChDB on AWS Lambda are the process's RAM usage, the amount of RAM required to run, the workload's memory consumption, and finally AWS Lambda's execution-time limit. These are the foundations of the trade-off between availability, performance, and solution cost.
🚨 DuckDB and ChDB generally present a challenge for data lakes: they may generate either many very small files or a single large file. This may lead to a need for more RAM, so review each engine's configuration to avoid this problem in your data architecture.
📌Proofs of concept are essential. In the ChDB code, using disk versus RAM in the Apache Parquet scenario made a noticeable difference in performance and execution viability. Validation is therefore very helpful for understanding what may happen in production.
🚀 There are many more technical aspects to review: ChDB's streaming mechanism, DuckDB's use of disk for processing, and the use of additional libraries in the process. Each of these could be the subject of a separate article, but this article provides a clear starting point.

With all this in mind, I reached the following conclusion: 🔥 I recommend using DuckDB as the baseline and evaluating ChDB as an alternative 🔥



References and additional resources

These are the resources that helped me, inspired me, or provide additional context for this article, and may help you explore this topic further:
🫶 Thanks to  Aki  for creating an excellent series that pioneered this topic and inspired this work.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article