Re: [squid-users] Squid 3.3.2 and SMP

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Fri, 08 Mar 2013 23:24:56 -0700

On 03/08/2013 07:40 PM, Amm wrote:

> is it possible that both workers will occupy same CPU?

Yes, it is not uncommon for two processes to share a CPU core,
especially when processes do not do much. You can even use SMP Squid on
single-core machines (e.g., for robustness). For best performance, it is
often a good idea to prevent such sharing though.

The following wiki page discusses some of these aspects:
http://wiki.squid-cache.org/Features/SmpScale

> Or is it that operating system takes care of it? Or does squid take care of it?

Both. OS scheduler determines process placement by default and Squid has
options to restrict worker placement to certain CPU cores. See
cpu_affinity_map in squid.conf.documented.

> If OS, how does OS (atleast Linux) do it? Does it alternate CPU for every new process.

There are several algorithms that Linux uses to assign CPU cores to
processes. The choice is configurable IIRC. I personally cannot describe
all the complex details, and it will probably too out of topic for this
mailing list.

FWIW, we usually see best performance results when using
cpu_affinity_map with 1:1 mapping between workers and cores (which
effectively disables those complex algorithms as far as Squid workers
are concerned).

> Lets say I have two cores and I use "workers 2" in squid.conf.
>
> Squid forks 1st worker and it lands on 1st core.
> But in between some other process starts (or forks) which lands on 2nd core
> Now squid forks 2nd worker and lands on 1st again?!
>
> Is this possible? (kind of race condition)

Without CPU affinity, processes such as workers change their cores
often. It is normal. You can see that for yourself if you add and watch
"last CPU used" column in "top" on a busy system.

HTH,

Alex.
Received on Sat Mar 09 2013 - 06:25:07 MST

This archive was generated by hypermail 2.2.0 : Sat Mar 09 2013 - 12:00:04 MST