You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often in projects, there is a need to perform deferred tasks,
7
-
such as sending email, push, and other tasks specific to the domain area of your application.
8
-
Difficulties begin when the usual crontab is no longer enough,
6
+
Often in projects, there is a need to perform deferred tasks,
7
+
such as sending email, push, and other tasks specific to the domain area of your application.
8
+
Difficulties begin when the usual crontab is no longer enough,
9
9
when batch processing is not suitable, when each task unit has its own execution time or it is assigned dynamically.
10
10
To solve this problem, a Trigger Hook was created. You can build a task scheduler based on this library.
11
11
@@ -25,11 +25,11 @@ Task | Description
25
25
26
26
Life cycle tasks:
27
27
- When creating a task, it gets into the database (square block) (red and yellow).
28
-
- Tasks are loaded into memory (triangular block) if their start time is coming soon (red->yellow).
28
+
- Tasks are loaded into memory (triangular block) if their start time is coming soon (red->yellow).
29
29
This structure is implemented in the form of a prioritized queue (heap).
30
-
- When the task execution time comes, it is sent for execution (yellow->green).
30
+
- When the task execution time comes, it is sent for execution (yellow->green).
31
31
An intermediate buffer is used before processing to compensate for peak loads.
32
-
- If the task is successfully submitted, it is deleted from the database (green->blue).
32
+
- If the task is successfully submitted, it is deleted from the database (green->blue).
33
33
An intermediate buffer is used before deletion, also to compensate for peak loads.
34
34
35
35
@@ -39,7 +39,7 @@ Metric|Description
39
39
---|---
40
40
All|Total number of tasks
41
41
Creating rate | Number of created tasks (via the Create method) per unit of time.
42
-
Deleting rate | Number of deleted tasks (via the Delete method) per unit of time.
42
+
Deleting rate | Number of deleted tasks (via the Delete method) per unit of time.
43
43
Sending rate | The number of processed tasks (via the Consume method) per unit of time.
44
44
Preloaded | The number of tasks preloaded into memory.
45
45
Preloading rate | The number of tasks loaded per unit of time.
@@ -48,14 +48,14 @@ Waiting for confirmation | The number of tasks waiting for confirmation after se
48
48
Confirmation rate | The number of confirmed tasks after sending per unit of time.
49
49
50
50
### Demo
51
-
[Use the demo](https://github.com/pvelx/k8s-message-demo)
51
+
[Use the demo](https://github.com/pvelx/k8s-message-demo)
52
52
[Read the article](https://vlad-pavlenko.medium.com/deferred-tasks-in-a-microservice-architecture-8e7273089ee7)
53
53
54
54
### Features
55
55
- Simple API.
56
56
- Performing tasks with second precision.
57
57
- High performance of sending tasks for execution. This is achieved through a simple task storage scheme, indexing, and multithreaded database access.
58
-
- High peak performance. Tasks that will be completed soon are loaded into memory in advance. This is especially important, for example, if several hundred thousand tasks are assigned at one time.
58
+
- High peak performance. Tasks that will be completed soon are loaded into memory in advance. This is especially important, for example, if several hundred thousand tasks are assigned at one time.
59
59
- The system is durable to failures. Only after the task is completed, the task is deleted from the database. This ensures that the task is sent for execution. The sudden stop of the application will not lead to inconsistent data in the database.
60
60
- It is designed for a micro-service, event-driven architecture. It is easy to implement a fully asynchronous API.
61
61
- The modular structure of the library. You can easily replace any part with your own implementation.
0 commit comments