<@U04S8PLJWMT> What's the best strategy for syncin...
# ask-ai
z
@kapa.ai What's the best strategy for syncing 32 million records? This only needs to happen once because I'll be using incremental loading for future syncs.
k
For a one-time sync of 32 million records, the best strategy—based on Airbyte community discussions and documentation—is to avoid a full refresh of the entire dataset if possible, as this can be slow, error-prone, and susceptible to failures, especially with large files or unreliable sources. Recommended approach: 1. Split the Initial Load (if possible): - If your source or destination supports it, break the data into smaller chunks or batches. This reduces the risk of timeouts and makes recovery from failures easier. However, Airbyte does not natively support splitting a single large sync into multiple smaller ones out of the box, though this is a requested feature by the community and is under consideration for future improvements [Break long and large data syncs into multiple small syncs](https://github.com/airbytehq/airbyte/issues/13783). 2. Direct Database Load (if available): - If you have access to the underlying data (e.g., a database dump or CSV), consider loading the data directly into your destination (e.g., Postgres, BigQuery) using native tools, then use Airbyte for incremental syncs going forward. This is a common workaround for sources with unreliable APIs or very large initial loads [Are there alternate methods for initial data loading?](https://discuss.airbyte.io/t/1836). 3. Partial Resync via Filtered Connections: - If you only need to re-ingest a subset of records (e.g., those created or updated in a certain time window), set up a separate Airbyte connection to sync just that subset. This is a recommended approach for large tables where a full refresh is impractical [Recommended approach to performing a one-time partial data resync?](https://discuss.airbyte.io/t/1992). 4. Monitor and Tune Resources: - Ensure your Airbyte deployment and destination database have sufficient resources (CPU, memory, disk) to handle the large load. Monitor for errors such as "Canceling Destination" which can occur if the destination cannot keep up with the incoming data [Canceling Destination on large local CSV file import to Postgres](https://discuss.airbyte.io/t/2447). Summary: If you can, load the initial 32 million records directly into your destination using native tools, then configure Airbyte to start incremental syncs from that point forward. If you must use Airbyte for the initial load, consider splitting the data or using filtered connections to reduce the load size, and ensure your infrastructure is robust enough to handle the operation. If you encounter failures during the sync, Airbyte's checkpointing and state management features can help you resume from the last successful point, but for very large one-time loads, direct database import is often the most reliable and efficient method [Are there alternate methods for initial data loading?](https://discuss.airbyte.io/t/1836), [Canceling Destination on large local CSV file import to Postgres](https://discuss.airbyte.io/t/2447).
z
@kapa.ai Why exactly isn't Airbyte able to handle this? Does it load the entire table into memory, then write to the destination?
k
A message from kapa.ai
Airbyte does not load the entire table into memory at once, but it does read data in batches—typically up to 10,000 records at a time. The main memory usage comes from the Source worker, which reads these batches into memory before passing them to the Destination worker. If the average row size is large, this batching can require significant memory (e.g., 10,000 records × row size), potentially leading to out-of-memory (OOM) errors for very large tables or wide rows. This is a known limitation and is discussed in both the documentation and community forums [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214). For example, if each row is 0.5 MB, then a batch of 10,000 rows would require about 5 GB of RAM. This batching approach is why Airbyte can struggle with very large tables or tables with large row sizes, especially if the available memory is not sufficient. The system does not currently batch based on total byte size, but rather on record count, which can be problematic for tables with variable or large row sizes [Reads should batch on bytes read instead of records read](https://github.com/airbytehq/airbyte/issues/3439). In summary: - Airbyte reads data in batches (not the whole table at once), but the batch size is based on record count, not memory usage. - Large tables or wide rows can cause high memory usage and potential failures. - This is a known limitation, and improvements are being discussed in the community and GitHub issues. If you encounter memory issues, you may need to increase the memory allocated to your Airbyte workers or consider alternative strategies for the initial load, as discussed previously.
z
@kapa.ai Is there an option to reduce the batch size for certain tables or connections?
k
A message from kapa.ai
Currently, Airbyte does not provide a user-facing option to configure or reduce the batch size for specific tables or connections in the UI or connection settings. The batch size (for example, the number of records read into memory at once) is set internally by Airbyte and is not exposed as a configurable parameter for most connectors. For database sources, Airbyte reads data in batches—typically up to 10,000 records at a time. This batch size is not user-configurable, and the system does not currently allow you to set a lower batch size for individual tables or connections. This limitation is acknowledged in both the documentation and community discussions. There have been requests and open issues to allow batch size configuration, especially to help with memory usage for large or wide tables, but as of now, this feature is not available [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214), [Reads should batch on bytes read instead of records read](https://github.com/airbytehq/airbyte/issues/3439). Some connectors (like the ClickHouse destination) have recently added options to configure batch size, but this is not a general feature across all connectors and is not available for most sources or destinations yet [ClickHouse Changelog](https://docs.airbyte.com/integrations/destinations/clickhouse#changelog). Summary: You cannot currently reduce the batch size for specific tables or connections in Airbyte. Batch size is managed internally and is not exposed as a user-configurable setting for most connectors.
z
@kapa.ai Is it possible to configure the number of retries on a sync?
k
A message from kapa.ai
Yes, it is possible to configure the number of retries for sync jobs in Airbyte, but this is done at the platform or environment level, not per individual connection through the UI. For open-source/self-hosted Airbyte, you can set environment variables to control retry behavior, such as: -
SYNC_JOB_MAX_ATTEMPTS
(legacy, superseded by the variables below) -
SYNC_JOB_RETRIES_COMPLETE_FAILURES_MAX_SUCCESSIVE
-
SYNC_JOB_RETRIES_COMPLETE_FAILURES_MAX_TOTAL
-
SYNC_JOB_RETRIES_PARTIAL_FAILURES_MAX_SUCCESSIVE
-
SYNC_JOB_RETRIES_PARTIAL_FAILURES_MAX_TOTAL
These variables define how many times Airbyte will retry a sync job after failures, both for complete and partial failures. You can find more details in the documentation [Configuring Airbyte - Jobs](https://docs.airbyte.com/platform/next/operator-guides/configuring-airbyte#jobs). Currently, Airbyte does not support configuring the retry count per connection via the UI or API. This feature has been requested by users but is not available as of now [Dynamically configure retries per connection](https://github.com/airbytehq/airbyte/issues/21147). Summary: You can configure the number of retries globally for your Airbyte instance using environment variables, but not per connection through the UI or API at this time.
z
@kapa.ai How much memory does an Airbyte job need to move 5GB of data?
k
A message from kapa.ai
The amount of memory an Airbyte job needs to move 5GB of data depends primarily on the average row size and the batching behavior of the connector, rather than just the total data size. Airbyte’s Source worker reads up to 10,000 records into memory at a time. If your table has an average row size of 0.5MB, then a single batch would require about 5GB of RAM (0.5MB × 10,000 = 5,000MB = 5GB). If your rows are smaller, the memory requirement will be proportionally less. For example, if each row is 0.05MB, a batch would require about 500MB of RAM. Key points: - Airbyte does not load the entire 5GB into memory at once. - The main memory usage comes from the largest batch in memory, not the total data size. - If your rows are large, you may need to allocate more memory to avoid out-of-memory errors. This batching behavior is a known limitation and is discussed in the documentation and community forums [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214), [Reads should batch on bytes read instead of records read](https://github.com/airbytehq/airbyte/issues/3439). Summary: To estimate memory needs, multiply your average row size by 10,000. For example: - 0.5MB × 10,000 = 5GB RAM needed for a batch. - 0.05MB × 10,000 = 500MB RAM needed for a batch. If you are unsure of your average row size, it is safest to over-provision memory and monitor usage during the sync.
z
@kapa.ai I can see from the UI that the job synced 7GB of data but needed at least 32GB of memory to run. How is this possible?
k
A message from kapa.ai
This situation can occur because Airbyte reads data in batches based on the number of records (typically up to 10,000 records at a time), not the total byte size. If your records are large (for example, each row is several megabytes), a single batch can require a very large amount of memory—even if the total data synced is only 7GB. For example, if each record is about 3MB, then a batch of 10,000 records would require about 30GB of RAM (3MB × 10,000 = 30,000MB = 30GB). This means that even if the total data synced is 7GB, the peak memory usage during the sync could be much higher, depending on the size of individual records and how the connector batches them in memory. This is a known limitation and is discussed in the Airbyte documentation and community forums [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214), [Reads should batch on bytes read instead of records read](https://github.com/airbytehq/airbyte/issues/3439). In summary, the high memory requirement is due to the way Airbyte batches records in memory, not the total amount of data being synced. If your rows are large, you may need significantly more memory than the total data size would suggest.
z
@kapa.ai I'm not understanding why the total memory might need to be "significantly" higher than the total size of a table.
k
A message from kapa.ai
The total memory required by Airbyte during a sync can be significantly higher than the total size of a table because of how Airbyte batches records in memory. Airbyte's Source worker reads up to 10,000 records into memory at a time, regardless of their size. If your records are large, this batch can consume a lot of memory—even more than the total size of the table being synced. For example, if each record is 2MB, a single batch would require 20GB of RAM (2MB × 10,000). If the table is 7GB in total, but the batch size is large and the records are wide, the memory needed at any moment could far exceed the table's total size. This is because Airbyte does not stream one record at a time, but rather processes large batches, and the memory is allocated for the entire batch before writing to the destination. This behavior is a known limitation and is discussed in the documentation and community forums [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214), [Reads should batch on bytes read instead of records read](https://github.com/airbytehq/airbyte/issues/3439). In summary: The memory requirement is determined by the size of the largest batch in memory, not the total table size. If your records are large, the batch can require much more memory than the total data being synced.
z
@kapa.ai Wouldn't the average size of a batch be (total size of table) / 10000?
k
A message from kapa.ai
No, the average size of a batch is not simply (total size of table) / 10,000. The batch size in memory depends on the number of records per batch (typically 10,000) multiplied by the average size of each record. If your table has 10,000 records total, then yes, the entire table would be one batch, and the batch size would be the total table size. But if your table has, for example, 1,000,000 records, each batch will contain 10,000 records, and the size of each batch will be approximately (average row size) × 10,000. The key point is that Airbyte reads up to 10,000 records into memory at a time, and if your records are large, a single batch can be very large in memory—even if the total table size is not huge. This is why memory requirements can be much higher than you might expect just by looking at the total table size [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214). So, the batch size in memory = (average row size) × 10,000, not (total table size) / 10,000.
z
@kapa.ai Wouldn't the average row size be (total table size) / (number of rows)?
k
A message from kapa.ai
Yes, your understanding is correct: The average row size is calculated as (total table size) / (number of rows). This is a standard way to estimate the average size of each record in a table. For example, if your table is 10GB in size and contains 10 million rows, the average row size would be approximately 1KB. This calculation is also referenced in Airbyte documentation and community discussions when estimating memory requirements for batch processing. For instance, the documentation provides an example: > "a table with an average row size of 0.5MBs will require 0.5 * 10,000 / 1000 = 5GBs of RAM" where the average row size is used to estimate the memory needed for a batch of 10,000 records [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte). So, to estimate memory requirements for Airbyte syncs, you can use this formula to determine the average row size.
z
@kapa.ai How much RAM should I provision to sync a 5GB table containing 5000000 rows? Show me the calculation.
k
A message from kapa.ai
To estimate how much RAM you should provision for syncing a 5GB table with 5,000,000 rows using Airbyte, you can follow this calculation based on Airbyte’s batching behavior: 1. Calculate the average row size:
Copy code
Average row size = Total table size / Number of rows                     = 5 GB / 5,000,000                     = 5,000 MB / 5,000,000                     = 0.001 MB per row                     = 1 KB per row
2. Estimate the memory needed for a batch: Airbyte reads up to 10,000 records into memory at a time during syncs.
Copy code
Batch size in memory = Average row size × Batch size                        = 1 KB × 10,000                        = 10,000 KB                        = 10 MB
Conclusion: You should provision at least 10 MB of RAM for the batch itself. However, in practice, you need to account for additional overhead from the Airbyte process, Java runtime, and other system operations. Airbyte documentation recommends over-provisioning memory to avoid out-of-memory errors, especially for larger or more complex tables. For most use cases, starting with at least 1–2 GB of RAM is recommended, even if your calculated batch size is much smaller, to ensure stability and account for overhead [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214). Calculation summary: - Average row size: 1 KB - Batch size in memory: 10 MB - Recommended minimum RAM (including overhead): 1–2 GB If your rows are wider or you have additional transformations, you may need more RAM. Always monitor your sync jobs and adjust as needed.
z
@kapa.ai This seems to contradict what you said earlier. In this case, the provisioned RAM is less than the total size of the table. Under what situations will the provisioned RAM need to be more than the size of the table? Provide a calculation.
k
A message from kapa.ai
Great question! The provisioned RAM required for an Airbyte sync can exceed the total size of the table when the average row size is large. This is because Airbyte batches records by count (typically 10,000 records per batch), not by total byte size. If each record is very large, a single batch can require more memory than the total table size. ### Example Calculation Suppose you have a table with: - Total size: 5 GB - Number of rows: 100,000 Average row size:
Copy code
5 GB / 100,000 rows = 0.00005 GB/row = 50 KB/row
Batch size in memory:
Copy code
Batch size = 10,000 records × 50 KB = 500,000 KB = 500 MB
Now, imagine a more extreme case: - Total size: 5 GB - Number of rows: 2,500 Average row size:
Copy code
5 GB / 2,500 rows = 2 MB/row
Batch size in memory:
Copy code
Batch size = 10,000 records × 2 MB = 20,000 MB = 20 GB
But here’s the catch: Airbyte will still try to batch up to 10,000 records at a time, even if the total number of rows is less than 10,000. If you had, say, 10,000 rows at 2 MB each, the batch would be 20 GB—**four times the total table size**. ### Why does this happen? - Airbyte’s batching is based on record count, not byte size. - If your table has a small number of very large records, a single batch can require more memory than the total table size. - This is a known limitation and is discussed in the Airbyte documentation and community forums [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [Reads should batch on bytes read instead of records read](https://github.com/airbytehq/airbyte/issues/3439). In summary: Provisioned RAM may need to exceed the total table size when the average row size is large, because Airbyte batches by record count, not by total bytes. This can lead to situations where a single batch in memory is larger than the entire table on disk.
z
@kapa.ai In your "extreme case", I don't understand why Airbyte would read 10,000 rows if the table only has 2,500 rows.
k
A message from kapa.ai
You're absolutely right—if the table only has 2,500 rows, Airbyte will not attempt to read 10,000 rows in a batch. Instead, it will read all available rows, so the maximum batch size would be 2,500 records in this case. The 10,000-record batch size is an upper limit, not a minimum or fixed requirement. This is confirmed in the documentation, which states that the Source worker "reads up to 10,000 records in memory" [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte). So, in your "extreme case" with only 2,500 rows, Airbyte would read all 2,500 records in a single batch, and the memory required would be:
Copy code
2,500 records × 2 MB = 5,000 MB = 5 GB
This means the memory required would match the total table size, not exceed it. The scenario where memory usage exceeds the total table size only occurs when the number of rows is large enough that a single batch (up to 10,000 records) contains more data than the total table size, due to very large average row sizes. Thank you for catching this!
z
@kapa.ai How would a single batch of rows contain "more data than the total table size"?
k
A message from kapa.ai
A single batch of rows cannot contain more data than the total table size. By definition, the total table size is the sum of all its rows. If Airbyte reads up to 10,000 records in a batch, the maximum data in memory for a batch is the lesser of (number of rows in the table) × (average row size) or 10,000 × (average row size). If the table has fewer than 10,000 rows, the batch will be smaller. The confusion arises when discussing scenarios with very large average row sizes and large tables. In such cases, a single batch (10,000 records) can require a large amount of memory, but it will never exceed the total size of the table itself. The memory requirement can, however, be much larger than expected if you only consider the total table size and not the batch size and average row size [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte), [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214). If the table has fewer than 10,000 rows, Airbyte will only read what's available, so the batch size in memory will never exceed the total table size.
z
@kapa.ai It appears you were/are very confused on this topic. How much extra RAM should be provisioned for other parts of the sync? Are there any rules of thumb?
k
A message from kapa.ai
You're right to ask for clarity on how much extra RAM should be provisioned for parts of the sync beyond just the batch size calculation. According to the available Airbyte documentation and community discussions, there is no strict rule of thumb or formula provided for the exact amount of extra RAM to provision for Airbyte syncs. However, several best practices and recommendations are mentioned: - Batch Size Calculation: The main memory usage comes from the batch of records read into memory (up to 10,000 records × average row size) during sync jobs. This is the primary driver of memory needs for the sync process itself [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte). - Additional Overhead: You should account for additional memory overhead from: - The Airbyte worker process itself - The Java runtime (for Java-based connectors) - Other containers and system processes running alongside the sync job - Best Practice: The documentation and community recommend over-provisioning memory beyond your calculated batch size to avoid out-of-memory errors, especially for larger or more complex tables. For most use cases, starting with at least 1–2 GB of RAM is recommended, even if your calculated batch size is much smaller, to ensure stability and account for overhead [How memory request and limit works under the hood](https://discuss.airbyte.io/t/2214), [Scaling Airbyte](https://docs.airbyte.com/platform/next/operator-guides/scaling-airbyte). - Monitoring: It is also recommended to monitor your sync jobs and adjust memory allocation as needed, since actual requirements can vary depending on connector implementation and data characteristics. Summary: There is no strict rule of thumb, but you should always provision extra RAM beyond the batch size calculation to account for process and system overhead. Starting with 1–2 GB of RAM (or more for large/complex syncs) is a common best practice, and you should monitor and adjust as needed based on your environment and sync performance. If you need more precise guidance, you may need to experiment and observe memory usage during actual syncs, as the documentation does not provide a definitive formula.