I have been working for a distributed process. In generic term this is a process which needs to run continuously in a distributed manner by following push-pull communication. RabbitMQ is a great tool to achieve this solution. I’ve extended worker model to integrate publisher along with the same. Continue reading
Supervisord is a simple and popular choice for process monitoring. Supervisord‘s primary purpose is to create and manage processes based on data in its configuration file. It does this by creating subprocesses. Each subprocess spawned by supervisor is managed for the entirety of its lifetime by supervisord. Continue reading
Last week I had a requirement to fetch details of some records. For simplicity let’s assume records are id of some entity; I need to get details from an API for those id. Let’s also assume that API accepts 100 id at maximum in a single request. I’d almost 1 million id to fetch details.
I love concurrency. Writing a concurrent program is always complex. There are different technologies which are most suitable to do this job. In an earlier post I briefed how to achieve parallelization using PHP. Parallel processing can be done using shell script also; by spawning multiple child processes. It’s fairly simple to handle basic concurrent tasks in that manner.
A basic example to achieve the same-
There are situations when we need to make our one-process task into a multi-process task so that we can take advantage of the operating system’s multitasking capabilities.
The basic conceptual difference between multiprocessing and multithreading– A process, is a unique instance of a program with its own memory space, own process ID number etc. Whereas, a thread can be thought of as a virtual process, it does not have its own process ID, does not have its own memory space, but is still able to take advantage of multitasking.
Without thread, parallelism is incomplete. Multithreading in PHP with pthreads:
From PHP DOC–
pthreads is an Object Orientated API that allows user-land multi-threading in PHP. It includes all the tools you need to create multi-threaded applications targeted at the Web or the Console. PHP applications can create, read, write, execute and synchronize with Threads, Workers and Threaded objects.
The issue is with this is a PECL extension. Not bundled in PHP library by default yet.
pthreads releases are hosted by PECL and the source code by » github, the easiest route to installation is the normal PECL route.
So now the question is there any minimal alternative to achieve the goal?