- In general, there are two ways / paradigms asynchronism can be done:
- Async #1
- doing the time-consuming work in advance and serving the finished work with a low request time.
- Very often this paradigm is used to turn dynamic content into static content. Pages of a website, maybe built with a massive framework or CMS, are pre-rendered and locally stored as static HTML files on every change. Often these computing tasks are done on a regular basis, maybe by a script which is called every hour by a cronjob.
- Async #2
- handle tasks asynchronously
- The basic idea is to have a queue of tasks or jobs that a worker can process.
- If you do something time-consuming, try to do it always asynchronously.