什么是ruby / rails的工人?

时间:2022-01-14 12:29:50

I am coming from the Java world and keep hearing this term 'worker' in the ruby/rails world. What is it? a thread?

我来自Java世界,并在ruby / rails世界中继续听到这个术语“工人”。它是什么?一个帖子?

3 个解决方案

#1


30  

Depends on the context.

取决于具体情况。

A worker is typically a process that runs outside of your application request cycle. Ruby libraries like resque and delayed_job are typically used to manage worker queues.

工作程序通常是在应用程序请求周期之外运行的进程。像resque和delayed_job这样的Ruby库通常用于管理工作队列。

On the other hand, if we're talking about web servers the word "worker" is sometimes used interchangeably with threads or processes (ie: nginx or apache "workers").

另一方面,如果我们谈论Web服务器,“worker”这个词有时可以与线程或进程互换使用(即:nginx或apache“workers”)。

#2


7  

Often in the 'Rails world' a worker is referring to a priority queue type system that has separate processes popping off tasks to execute outside the application cycle. One of the most popular of these systems is DelayedJobs. This uses a database migration to add a table to hold the tasks that are to be executed by a worker process. You can then configure any number of worker processes that will check the DelayedJobs queue table and execute the serialized task. With DelayedJobs you have not only the ability to set priority of different tasks, but also a timeframe to execute the task, eg. send a particular email 1 hour from now.

通常在“Rails世界”中,工作者指的是优先级队列类型系统,该系统具有单独的进程弹出任务以在应用程序周期之外执行。 DelayedJobs是这些系统中最受欢迎的系统之一。这使用数据库迁移来添加表以保存工作进程要执行的任务。然后,您可以配置任意数量的工作进程,这些进程将检查DelayedJobs队列表并执行序列化任务。使用DelayedJobs,您不仅可以设置不同任务的优先级,还可以执行任务的时间范围,例如。从现在起1小时发送特定电子邮件。

#3


3  

A server running your rails app uses workers to do all of the things an application needs. It sends email, runs requests, performs calculations etc. The number of workers you need depends on how much traffic and calculations your web app needs to do.

运行rails应用程序的服务器使用worker来完成应用程序所需的所有操作。它会发送电子邮件,运行请求,执行计算等。您需要的工作人员数量取决于您的Web应用程序需要执行的流量和计算量。

#1


30  

Depends on the context.

取决于具体情况。

A worker is typically a process that runs outside of your application request cycle. Ruby libraries like resque and delayed_job are typically used to manage worker queues.

工作程序通常是在应用程序请求周期之外运行的进程。像resque和delayed_job这样的Ruby库通常用于管理工作队列。

On the other hand, if we're talking about web servers the word "worker" is sometimes used interchangeably with threads or processes (ie: nginx or apache "workers").

另一方面,如果我们谈论Web服务器,“worker”这个词有时可以与线程或进程互换使用(即:nginx或apache“workers”)。

#2


7  

Often in the 'Rails world' a worker is referring to a priority queue type system that has separate processes popping off tasks to execute outside the application cycle. One of the most popular of these systems is DelayedJobs. This uses a database migration to add a table to hold the tasks that are to be executed by a worker process. You can then configure any number of worker processes that will check the DelayedJobs queue table and execute the serialized task. With DelayedJobs you have not only the ability to set priority of different tasks, but also a timeframe to execute the task, eg. send a particular email 1 hour from now.

通常在“Rails世界”中,工作者指的是优先级队列类型系统,该系统具有单独的进程弹出任务以在应用程序周期之外执行。 DelayedJobs是这些系统中最受欢迎的系统之一。这使用数据库迁移来添加表以保存工作进程要执行的任务。然后,您可以配置任意数量的工作进程,这些进程将检查DelayedJobs队列表并执行序列化任务。使用DelayedJobs,您不仅可以设置不同任务的优先级,还可以执行任务的时间范围,例如。从现在起1小时发送特定电子邮件。

#3


3  

A server running your rails app uses workers to do all of the things an application needs. It sends email, runs requests, performs calculations etc. The number of workers you need depends on how much traffic and calculations your web app needs to do.

运行rails应用程序的服务器使用worker来完成应用程序所需的所有操作。它会发送电子邮件,运行请求,执行计算等。您需要的工作人员数量取决于您的Web应用程序需要执行的流量和计算量。