IMAP Account Sync 100% CPU LOAD

Hey, I already posted in #šŸ”ļø±general , but I was now able reproduce the problem. 1. Add a new IMAP with around 500+ Emails 2. check cpu load 3. Twenty will become unresponsive I currently use a VPS with 4GB RAM and 2vCPUs that 2 steps are able to make the vps completely unresponsive (no ssh login possible, twenty UI unresponsive, etc..) After an minute or two the server recovers or restarts because out of memory. With a smaller Inbox (50-100Mails) it’s working and the synced status appear nearly instant. Is this a known Issue?
96 Replies
DerPicknicker
DerPicknickerOP•3mo ago
Edit: the import process is also taking forever for even small inbox (500 mails). I started that process again while posting that thread and it’s still running. Is that normal? Update: Now it’s finalized but Sync is not showing all results For example x.yyy@z.com not working. X is the first letter of first name YYY is the last name Z is the domain XX@domain.com is also not every time appearing. Some yes but not all. Assuming my domain my domain is Google.com all my internal emails aren’t visible. Is that the way it should work? I did now a comparision. I would assume only 70% are synced (People & Companies) but from those only 30% of the Emails are visible.
DerPicknicker
DerPicknickerOP•3mo ago
No description
DerPicknicker
DerPicknickerOP•3mo ago
GitHub
IMAP causes heavy resource load Ā· Issue #14520 Ā· twentyhq/twenty
Bug Description If you change some IMAP Settings which triggers the Importing Logic, my VPS will become unresponsive. Which shouldn't happen for an imap import. Currently it uses 100% of the CP...
Prastoin
Prastoin•3mo ago
Hey @DerPicknicker,
Twenty will become unresponsive
The whole app ( server client and worker ) or just worker ? I assume you're using the one click install ? which means you're deploying the three of them on the same pods ( which would make sense for global outage if worker get overloaded )
DerPicknicker
DerPicknickerOP•3mo ago
Hey @prastoin , yes on same host.
Prastoin
Prastoin•3mo ago
I did now a comparision. I would assume only 70% are synced (People & Companies) but from those only 30% of the Emails are visible.
I don't really know email synchro implem details recover on failed chunk maybe you're missing the one that failed due to cpu issues
DerPicknicker
DerPicknickerOP•3mo ago
Maybe thats a coincedence.
Prastoin
Prastoin•3mo ago
From my understanding if it's the very for time your're importing your emails you could upgrade your cpu just for the duration of the initial import If you need to be able to handle same amount of email import volume then you will need more cpu In the other hand you could try deploying your worker on its own
DerPicknicker
DerPicknickerOP•3mo ago
For me its weird because even on a low powered device those inboxes arent big 500 mails is like a small one
Prastoin
Prastoin•3mo ago
So if it comes to fail it doesnot impact the twenty-server that will I think handle recovery of the failed import
DerPicknicker
DerPicknickerOP•3mo ago
Yes for sure but
Prastoin
Prastoin•3mo ago
Indeed that's pretty light
DerPicknicker
DerPicknickerOP•3mo ago
This doesnt make sense to me
Prastoin
Prastoin•3mo ago
Could you please confirm what twenty version you're using ?
DerPicknicker
DerPicknickerOP•3mo ago
1.5.3
Prastoin
Prastoin•3mo ago
Any error in worker logs ? I guess heap memory But if anything else might be helpful
DerPicknicker
DerPicknickerOP•3mo ago
I use an low power device for my HomeAssistant server that handles a music library and 10 streams at same time with 20% CPU Load. So for me there must be something wrong šŸ˜‰ Should I trigger Re-Sync again and post docker compose logs?
Prastoin
Prastoin•3mo ago
Are you sure you allowed the correct cpu amount you're thinking of to the twenty instance ? Yep always a plus
DerPicknicker
DerPicknickerOP•3mo ago
I have 2Vcpus on my VPS instance
DerPicknicker
DerPicknickerOP•3mo ago
No description
DerPicknicker
DerPicknickerOP•3mo ago
Twenty is currently importing emails in backround (same inbox which I currently face this issue)
DerPicknicker
DerPicknickerOP•3mo ago
No description
Prastoin
Prastoin•3mo ago
Ok cool That's some neat graph haha
DerPicknicker
DerPicknickerOP•3mo ago
No description
Prastoin
Prastoin•3mo ago
Ok so indeed there're might be an issue
DerPicknicker
DerPicknickerOP•3mo ago
Currently Using 1,9gb RAM directly after starting going up to 3,9gb (4gb is max) so this is also a bit problematic.
Prastoin
Prastoin•3mo ago
Unless I'm mistaken there's a new feature in the lab allowing a specific folder import If possible I would like you to try importing 500 times a basic email
DerPicknicker
DerPicknickerOP•3mo ago
You mean just simple Email without Responding / threads?
Prastoin
Prastoin•3mo ago
Yep
DerPicknicker
DerPicknickerOP•3mo ago
Hetzner hosting šŸ˜‰
Prastoin
Prastoin•3mo ago
I'd like to attest that this is not the volumes of 500 but the integrity of the initialy imported 500 emails that are causing the issue
DerPicknicker
DerPicknickerOP•3mo ago
Do you have an idea why it’s taking ages to finish the import ? Because after the spikes to 100% cpu load it’s taking hours to finalize Give me a second let me try
Prastoin
Prastoin•3mo ago
Take all your time no worries Hours not normal indeed
DerPicknicker
DerPicknickerOP•3mo ago
It took like 4hours yesterday After the spike @prastoin created now an inbox with 28 elements with attachments, blank emails, html ones. Let me force to update again.
DerPicknicker
DerPicknickerOP•3mo ago
After changing the credentials and directly turning off the inbox with 500 elements its still utilizing all cpu power
No description
Prastoin
Prastoin•3mo ago
Is top graph value 100% ?
DerPicknicker
DerPicknickerOP•3mo ago
yes
No description
DerPicknicker
DerPicknickerOP•3mo ago
And I found another bug
Prastoin
Prastoin•3mo ago
Could you please remove any attachements from the imported emails ? Please feel free to share
DerPicknicker
DerPicknickerOP•3mo ago
Its hard because the Inbox-selector always defaults back to the sent / inbox setting. So I always trigger a full importing which causes my server to be unresponsive. This is super annoying because I cannot test your needed things properbly.
DerPicknicker
DerPicknickerOP•3mo ago
Also funny this is the ssd bandwith while importing.
No description
DerPicknicker
DerPicknickerOP•3mo ago
Now one is successfully imported (<100 Mails) the other one is still importing (around 500) this seems fine.
No description
No description
DerPicknicker
DerPicknickerOP•3mo ago
@prastoin Here is my folder setting at the moment. After changing the credentials to trigger re-sync it falls back to sent and inbox.
No description
DerPicknicker
DerPicknickerOP•3mo ago
@prastoin the IMAP import seems to be partially broken. Because after setting only my test folder for reading emails are showing up which weren’t visible but not if I read my whole inbox in.
Prastoin
Prastoin•3mo ago
cc @NEO, will have more information than I regarding in wip IMAP integration
DerPicknicker
DerPicknickerOP•3mo ago
Thank you for all your support till here
Huzef
Huzef•3mo ago
@DerPicknicker Hi What provider are you using for email?
DerPicknicker
DerPicknickerOP•3mo ago
All-Inkl Its a german provider @NEO This provider works seamlessly on Windows and iDevices via IMAP.
Huzef
Huzef•3mo ago
Could you summarize the issue(s) so far you've had? just to confirm
DerPicknicker
DerPicknickerOP•3mo ago
Big Inbox (500 Mails) uses 1-3mins all CPU Power until nothing works anymore (I guess even unitl out of memory) small one (<100) works fine. I think this also causes that not all Emails are synced. And the Sync taking ages (4-5 Hours for the 500 Mail inbox). From my 500 Mails not all Contacts are created as person elements. And if created not all Emails are linked to that person. Even if the Frontend says its synced. Not all Emails are available from that Person. This HIGH cpu usage is like an ddos attack to my server even SSH is not working because its fully used by twenty (LOL). @NEO here is the graph for cpu usage
Huzef
Huzef•3mo ago
Interesting, will investigate and update you soon
DerPicknicker
DerPicknickerOP•3mo ago
Thank you for your support. If you need something please let me knwo. Maybe you could also check this. Maybe its related..
Huzef
Huzef•3mo ago
Your RAM allocation was 2GB right? and 2vCPUs?
DerPicknicker
DerPicknickerOP•3mo ago
4GB and 2VCPU
Huzef
Huzef•3mo ago
I see
DerPicknicker
DerPicknickerOP•3mo ago
the whole Server is 4GB Currently 2/4GB used. So quite relaxed.
Huzef
Huzef•3mo ago
This should be fixable I think, will update you Though (in my opinion) it's overkill to change credentials everyday if you use a strong generated password
DerPicknicker
DerPicknickerOP•3mo ago
thank you. Twenty is just awesome for me.. I am a Startup Company of 2 Guys and its blown my mind. Thank you for fixing... I am not changing everyday. From time to time. But the biggest problem is that saving credentials is the only way to force twenty to update the IMAP Folders. It would be better on the folder page a small refresh icon to get latest IMAP folders before syncing. And after making a change in the selected folders start the actual sync.
Huzef
Huzef•3mo ago
folders are auto synced when new messages are imported the process is inter linked
DerPicknicker
DerPicknickerOP•3mo ago
If I create a new Folder. I need to update the credentials without making a change that only makes them visible.. For me. I created, opened twenty and they arent visible until I click on connection settings, save. then the newly created folders will appear.
Huzef
Huzef•3mo ago
That's odd, but I should also mention new messages are imported periodically every 2 minutes so you wouldn't see a new folder instantly
DerPicknicker
DerPicknickerOP•3mo ago
I never waited 2 mins. Maybe they will appear but for me it would be more intuitive to have a small refresh icon for only the folder page.
Huzef
Huzef•3mo ago
I understand your perspective, will discuss it with Felix and get back to you
DerPicknicker
DerPicknickerOP•3mo ago
No problem take your time. Twenty is already awesome. I don’t want to criticize at all. Just testing currently a lot šŸ˜‰
Huzef
Huzef•3mo ago
Feedback is always welcome whether positive or negative
DerPicknicker
DerPicknickerOP•3mo ago
Just let me know if you need some more information.
Huzef
Huzef•3mo ago
Will do!
longbuibao
longbuibao•3mo ago
how can I create a trigger that match with specific value of Stage ? For example I only want to run the workflow when value of Stage is Meeting
No description
Prastoin
Prastoin•3mo ago
Hey @longbuibao, unless I'm mistaken this un-related to this help thread, please create a dedicated one šŸ™
DerPicknicker
DerPicknickerOP•3mo ago
@prastoin @NEO I just send now an Email to an Person which wasnt created via the IMAP Sync (I created that person). Now I copied the email into the Folder which I created here for testing purposes and that Email is never linked to the person (waited 5-8mins).
Huzef
Huzef•3mo ago
Hi, please don’t tag Paul I’m responsible for IMAP issues
DerPicknicker
DerPicknickerOP•3mo ago
Sorry wasnt aware which one is responsible.
Huzef
Huzef•3mo ago
I’m currently occupied with some other issue, but will investigate yours as soon as possible
DerPicknicker
DerPicknickerOP•3mo ago
No problem I don’t want to stress you in any way. Just playing around.
Huzef
Huzef•3mo ago
@DerPicknicker Quick update on syncing large mailbox ( > 500) I tested it locally and it synced fine, haven't profiled CPU and RAM usage yet it's tricky on macOS I'll need to setup linux VM
Huzef
Huzef•3mo ago
DerPicknicker
DerPicknickerOP•3mo ago
But also with threads? Or plain emails? Nearly 90% are email threads Just limit ram in docker engine And you could also limit cpu cores
Huzef
Huzef•3mo ago
I guess you could with some finnicking with volume mounts, I run bare metal for development Yes How big is your average email? is it plain text? HTML? inline content/attachment?
DerPicknicker
DerPicknickerOP•3mo ago
80% HTML Attachment sizes varies between 1-30MB Mostly as attachments.
Huzef
Huzef•3mo ago
Would it be possible to get some sample emails? you could DM me the info and of course redact any personal identifiers
DerPicknicker
DerPicknickerOP•3mo ago
We could also do a short call and I show you the email inbox and we can stress the import and Check logs together Or I create an inbox at my provider and you do your testing again
Huzef
Huzef•3mo ago
a .eml export for a few emails would suffice
DerPicknicker
DerPicknickerOP•3mo ago
Because I don’t see all emails too. So somewhere is something wrong with;)
Huzef
Huzef•3mo ago
Is your cron job setup correctly? sometimes that's the issue just narrowing down the possibilities
DerPicknicker
DerPicknickerOP•3mo ago
How to check?
DerPicknicker
DerPicknickerOP•3mo ago
No description
DerPicknicker
DerPicknickerOP•3mo ago
I face 3 Issues: - Copy email into a folder watched by twenty won’t show up - After synced with extensive resource consumption not all people are visible - After manually creating a user emails will never get matched to that person I have the feeling that this is caused by the usage consumption bug
Huzef
Huzef•3mo ago
Exclude non-professional emails is enabled by default
No description
Huzef
Huzef•3mo ago
The ones that didn't show did they happen to be gmail/outlook?
DerPicknicker
DerPicknickerOP•3mo ago
Nope custom domain
Huzef
Huzef•3mo ago
Okay let's try addressing the spike first Anything on this?
DerPicknicker
DerPicknickerOP•3mo ago
I am using not outlook. Give me some time to figure out
Huzef
Huzef•3mo ago
If you're macOS and use Mail.app you can drag the emails to desktop it will export them
DerPicknicker
DerPicknickerOP•3mo ago
I will do it in 2mins how many do you need?
Huzef
Huzef•3mo ago
I think 4-5 should be enough
DerPicknicker
DerPicknickerOP•3mo ago
Okay give me a second

Did you find this page helpful?