ERDDAP / erddap

ERDDAP is a scientific data server that gives users a simple, consistent way to download subsets of gridded and tabular scientific datasets in common file formats and make graphs and maps. ERDDAP is a Free and Open Source (Apache and Apache-like) Java Servlet from NOAA NMFS SWFSC Environmental Research Division (ERD).
Creative Commons Zero v1.0 Universal
84 stars 58 forks source link

Improve how emails are sent #48

Closed BobSimons closed 2 years ago

BobSimons commented 3 years ago

Currently, if ERDDAP needs to send an email, it (in the current thread) connects to the mail server, sends the email, and disconnects. This is inefficient (too much time repeatedly connecting to the server) and slow (it slows down the current thread). Often (e.g., for subscriptions) multiple emails are sent out in a short period of time.

At the very least, it would be good to have an email queue and dedicate a separate thread to sending emails. There is already a TaskThread, which manages some background tasks (e.g., downloading remote files). There is code to ensure it isn't stalled, recreate it if needed, and stop it when ERDDAP is shutting down. The EmailThread could mimic its system for thread maintenance.

Beyond that, perhaps that thread should be smart about letting emails accumulate in the queue before sending them as a group. For example, perhaps the system should wait 5 (or 10 or ?) seconds after an email is added to the queue in case other emails are also added during that time. Thus, emails would still go out quickly but would be more likely to be sent in a batch rather than individually.

Note that all emails get sent via EDStatic.email(), so it will be easy to modify that to add an email queue. And the TaskThread has thread management code, so you can just mimic that.

Skills required: Java programming. Since this involves threads, extra care must be taken to avoid problems.

Difficulty: Medium. You'll have to explore JavaMail's features to figure out how to optimize this. But I think it is a straightforward task. Perhaps 1-2 weeks (after you figure out ERDDAP).

Mentor: Bob Simons (main author of ERDDAP)

Please also read the Programmer's Guide at https://coastwatch.pfeg.noaa.gov/erddap/download/setup.html#programmersGuide especially the "Judging Your Code Contributions" section.

alyssachne commented 3 years ago

Hi,

I'm a second year computer science student from University of Toronto and I had used Java to write a meeting project. I'm very interested in this topic and I want to work on it. Would you mind giving me a chance to work on it? (Also I'm currently in my final period, I will work on this start on around April 20th.)

Wish everything goes well for you :)

BobSimons commented 3 years ago

Thanks for your interest in working on this project.

If you want to work on it on your own (not as part of Google Summer of Code), then let me know, I'll assign the project to you, and you can work on it in April.

If you want to be part of GSoC: My understanding of GSoC (from https://summerofcode.withgoogle.com/how-it-works/#timeline ) is that students like you submit applications until Apr 13. Then we review and select the best student proposals by May 17. If you are accepted, we "bond" from May 17 - June 7 and actually work on the project together from June 7 to Aug 16. So, what you can do now is:

Best wishes.

BobSimons commented 2 years ago

I did this. The changes will be in ERDDAP v2.19.