Task Parallelism: Different, independent tasks run simultaneously — e.g. resizing an image while compressing another. Task parallelism means running different, independent tasks at the same time. While one worker resizes images, another sends emails and a third generates a report. It differs from data parallelism, where the same operation is applied to many pieces of data. Here the tasks themselves are different, and they simply do not depend on each other.
What should you keep in mind with Task Parallelism?
In web applications, queues give you task parallelism naturally. Separate queues for emails, exports and integrations, each with its own workers, keep a slow export from delaying password reset emails. In code, running independent API calls concurrently, with promises in JavaScript or concurrent HTTP requests in Laravel, can cut response times considerably. Be sure the tasks really are independent, or you trade speed for race conditions.
Use when code runs things at the same time - threads, async/await, queues and workers, parallel requests, cron jobs, webhooks that retry - or when a bug only happens "sometimes" or under load. Covers race conditions, deadlocks, mutexes/locks, atomic operations, idempotency, message queues and backpressure, with Laravel and database examples.