Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parallel email creation to raise speed #26

Open
bernhardreiter opened this issue Aug 18, 2016 · 1 comment
Open

Allow parallel email creation to raise speed #26

bernhardreiter opened this issue Aug 18, 2016 · 1 comment

Comments

@bernhardreiter
Copy link
Member

bernhardreiter commented Aug 18, 2016

Right now only one mailgen variant can run at a time
and mailgen only uses one (python thread).

If email sending speed becomes an issue, it may be possible to enable
more email creation processes to work in parallel.

Possibilities:

  • allow to start several mailgen workers (from different machines)
  • use threads within mailgen (because sending and crypto will be i/o bound from mailgen's side)
  • make sure crypto processes can run on a different thread/core.

Both ideas will allow a machine with several cores to utilise them better.

If implemented, the sql interactions must be checked for race conditions.

Technically the use of SQL selections should right now prevent
an active second mailgen script to run.

@bernhard-herzog
https://github.com/Intevation/intelmq-mailgen/blob/master/intelmq-mailgen#L715
has FOR UPDATE NOWAIT
does this prevent mailmen from running twice like you've said?

@bernhard-herzog
Copy link
Member

That SELECT ... FOR UPDATE together with the fact that mailgen uses the same database transaction for reading the notification information and marking a notification as sent, takes care of the serialization. That is, only one mailgen process can work with a notification at any point in time.

The NOWAIT has the effect that if you try to start a second mailgen process while another one is still running, you will get an error immediately. Without it, the second one would block until the first one finishes (and then proceed to process at least some of the same notifications again, IIRC).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants