![]() You can throw up a “Loading…” spinner, but can we do better? A never-ending loading indicator in the browser tab, or worse, nothing happening for 20 seconds is not a good experience. Bad UX: even if your server weathers the extra load of slow actions, users may not be so patient.If even a few users are doing exports at the same time, you will hit your resource cap and see failed requests and Heroku “R14 - Memory Quota Exceeded” errors. For small files, this is fine but if you create 100+ MB files in memory, your RAM usage will spike up and down wildly. Memory spikes: the most straightforward implementations for file exporting generate a file in memory before serving it to the user.Platforms like Heroku will kill requests after 30 seconds and, in the mean time, your whole app slows down as workers/dynos are tied up with long running actions. You might have a report that is slow but just barely finishes, but you know that it scale linearly with the amount of data and will break soon. Request timeouts: once response times start creeping past 10+ seconds, you run the risk of timeouts. ![]() If you try building these kinds of reports in a normal Rails controller action, you will see these symptoms: So how do you know when it’s time to use background jobs? Or maybe you have to connect to an external API and process a whole bunch of data. An analyst needs a complicated Excel report. You need to export a large data set to a CSV file. In every non-trivial application you’ll have to do something that is just slow. In case you don’t like reading (Feb 2020 - Indy.rb Meetup)
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |