Hi
Import performance can be improved, but parallel processing should be enabled deliberately. It is not simply a safe speed increase: running several imports at the same time changes the order in which contact updates are applied.
For the normal scenario, I recommend:
- Use background imports instead of processing large CSV files in the browser.
- Run
mautic:import through cron or a dedicated worker.
- Verify that the
email column is indexed in the leads table.
- Import only the columns that are actually required.
- Split very large files into reasonable parts.
- Measure one worker first, then gradually increase the batch size or worker count.
Mautic has a setting that allows multiple imports to run concurrently. However, parallel imports are not equally safe in every scenario.
Main risk
Mautic does not know that one import is logically newer than another. For example:
- import
n contains older data;
- import
n+1 contains newer data;
- both files contain the same email addresses;
- both imports run at the same time.
Mautic does not compare the import number, source-file date, or business version of the row. The value written last to the database wins.
This can happen:
- Import
n+1 starts first and contains the current data.
- Import
n starts shortly afterwards.
- Import
n+1 finishes first.
- Import
n continues processing and writes the older values.
- The contact ends up containing outdated data again.
This may not produce an error in the interface. Both imports can finish successfully and their counters can look correct. The problem is the order in which the rows were applied.
What our testing showed
We tested this scenario on a clean Mautic 7.2.1 installation using synthetic databases with 100 and 1,000 contacts. Each scenario was repeated three times.
Results:
- sequential
n, then n+1 always left the n+1 values;
- sequential
n+1, then n always left the older n values;
- when
n+1 started first and both imports overlapped, the older n values remained in all six tests;
- when the start order was reversed, the newer values remained;
- with the ordinary queue path, the final state also depended on which worker actually wrote the rows last.
There were no duplicate contacts, deadlocks, or mixed values in the tested text, phone, and numeric fields. However, the absence of an error does not mean that the final data was the newest data.
A separate test also showed that if several workers start at exactly the same time, they can race while selecting queued imports. In that situation, more than one process may attempt to claim the same queued import. This is a separate queue race, but it further demonstrates why uncontrolled parallel execution can be risky.
When parallel imports are safer
Parallel processing is safer when:
- each file contains completely different contacts;
- the same email address cannot appear in multiple files at the same time;
- imports do not update the same contacts;
- an older export is not being re-imported;
- the update order does not matter;
- the database has sufficient CPU, memory, and I/O capacity.
If several files may contain the same email addresses, especially when updating existing contacts, sequential processing is safer.
Practical recommendation
Start with one worker and measure the result:
php bin/console mautic:import --limit=1000
Then gradually increase the batch size or worker count while monitoring:
- actual throughput;
- CPU and database load;
- the number of imports in progress;
- errors and delayed imports;
- final values for selected control contacts;
- duplicate contacts and stale overwrites.
Increasing the number of workers does not always make imports faster. In our testing with 60,000 contacts, a limit of 4 was safer and faster for mixed and update-heavy workloads than 8. A limit of 8 provided an advantage mainly for imports containing mostly new contacts.
In short, parallel imports can be useful for completely new, non-overlapping contacts. They can also cause newer data to be overwritten by older data when several files update the same email addresses.
In other words, in this scenario, sequential importing is not simply a slower option. It preserves the intended business logic for processing the data. Parallel importing without version control may provide higher throughput, but it can also make the final state of contacts nondeterministic.