A SharedWorker context is a stateful session and is designed to multiplex web pages into one application through asynchronous messaging (client / server paradigm). Its life cycle is based on a domain, not on a single page, like DedicatedWorker (a two-level paradigm).
The ServiceWorker context is designed to be inactive. This is actually not a permanent session - it is an inversion of management (IoC) or an event-based service paradigm. It caters for stateless events, not stateful pages.
One goal is to provide concurrent secure asynchronous endpoints for long queries (LRQ) for databases and other storage services (such as the cloud). Exactly what the thread pool does in other languages.
For example, if your web application runs many concurrent secure LRQs for various cloud services to populate itself, ServiceWorkers is what you want. You can execute dozens of secure LRQs in seconds without blocking the user's work. SharedWorkers and DedicatedWorkers have a hard time managing multiple concurrent secure LRQs. In addition, some browsers do not support SharedWorkers .
Perhaps they should have called ServiceWorkers : CloudWorkers for clarity, but not all services are clouds.
We hope this explanation should make you think about how different types of workers were designed to work together. Each of them has its own specialization, but the overall goal is to reduce DOM latency and improve the user interface in web applications.
Download some WebSockets for push notifications and WebGL for graphics, and you can create some hot smoking web applications that work like multi-user console games.
Dominic Cerisano Nov 27 '16 at 1:58 2016-11-27 01:58
source share