# Huge server load processing digests after import

**URL:** https://meta.discourse.org/t/huge-server-load-processing-digests-after-import/86874
**Category:** Support
**Tags:** activity-summary
**Created:** [May 6, 2018, 12:27pm UTC](https://meta.discourse.org/t/huge-server-load-processing-digests-after-import/86874 "2018-05-06T12:27:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [May 6, 2018, 12:27pm UTC](https://meta.discourse.org/t/huge-server-load-processing-digests-after-import/86874/1 "2018-05-06T12:27:35Z")

</div>

Hi,

after running an import with 300k users, I found that running the weekly digest is a bit of an issue: the server will queue 100k emails at once and processing them is hard on the machine - the load spikes up (about 10x), making the site very slow for a hours. I suppose this is an edge case of running an import - with organic signups these will be distributed more evenly throughout the week, making this less of an issue.

For now, I’ve flushed the email jobs and stopped generating digests, but I’d like to re-enable them.

What’s the recommended strategy for handling this - is there a way to ‘spread out’ the generation of the digests?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [May 7, 2018, 2:51pm UTC](https://meta.discourse.org/t/huge-server-load-processing-digests-after-import/86874/2 "2018-05-07T14:51:46Z")

</div>

It sounds like most of your users have the same `last_seen_at` value. Usually import scripts set it to the user’s `created_at` or `last_posted_at` date & time.

> <https://github.com/discourse/discourse/blob/main/script/import_scripts/base.rb#L739-L745>

Maybe that didn’t happen or lots of users have it set to the same time… Try updating the `last_seen_at` column with random times so that it evenly distributes the digest mails throughout the day.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [May 7, 2018, 3:24pm UTC](https://meta.discourse.org/t/huge-server-load-processing-digests-after-import/86874/3 "2018-05-07T15:24:04Z")

</div>

Exactly this, also if your import data didn’t had an explicit field for `last_seen_at`, you should update with it with the timestamp of their last post.

This way, a lot of those 300k users will not get the digest, because the date will be greater than `suppress digest email after days`.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 17, 2020, 4:14am UTC](https://meta.discourse.org/t/huge-server-load-processing-digests-after-import/86874/4 "2020-10-17T04:14:26Z")

</div>


