Forum Moderators: phranque

Message Too Old, No Replies

What does mod unique id actually do?

         

csdude55

12:44 am on Nov 26, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I see that Apache says:

Unique request identifier module for the Apache HTTP Server (causes noticeable performance degradation)

but the docs are hard to understand.

Do I need this if I use PHP session IDs? If I turn it off, what all do I lose?

phranque

1:02 am on Nov 26, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Do I need this if I use PHP session IDs?

no.
If I turn it off, what all do I lose?

you won't have a UNIQUE_ID environment variable:
Apache Module mod_unique_id [httpd.apache.org]

csdude55

6:45 am on Nov 27, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I can't think of any way that I use this... I honestly didn't even know it existed. I use PHP sessions, and I would have thought it would be the same unique ID, but I guess not.

Do you know if Wordpress or any other common template program uses them in any way? If so then some of my hosting clients might suffer if I remove it. But if not then it sounds like removing it might improve my server's performance a little.

robzilla

8:01 am on Nov 27, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



UNIQUE_ID is unique to Apache, I believe, so no. Otherwise WordPress et al. would be dependent on Apache.

wilderness

11:54 pm on Nov 27, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is that what this is?

[webmasterworld.com...]

robzilla

12:36 am on Nov 28, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is that what this is?

No, the unique id will be stored in the $_SERVER environment variable (not usually visible in your log files).

It will look something like this: U09ZosCoABMAAC9CATgAAAAA

csdude55

5:55 am on Nov 28, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What is it actually used for, then?

robzilla

11:18 am on Nov 28, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Makes it easier to trace individual requests, e.g. for debugging, particularly in multi-server environments (clusters of Apache servers).

phranque

10:12 pm on Nov 28, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What is it actually used for, then?

Above I linked to the Apache document that describes what it is used for.

JorgeV

12:28 pm on Nov 29, 2020 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



Hello,

I am not using Apache, but if I don't make mistake mod_unique_id provides a unique id fore each "request", not "users". So it's totally unrelated to PHP session ID.

csdude55

9:11 pm on Nov 29, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Haha, I know, @phranque... RTFM! LOL I promise that I read it, it's just complicated to understand. There was a time that I would pretend to understand and say, "oh, OK, cool". But I'm way past that point, now I'd rather actually understand it so that I can make educated decisions without messing up :-)

So.

It's my understanding that it's mainly for 32 bit operating systems so that it can make sure that the Apache pid is unique. Right? Does that mean that my 64 bit CentOS doesn't need it for that?

robzilla

10:12 pm on Nov 29, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's my understanding that it's mainly for 32 bit operating systems so that it can make sure that the Apache pid is unique. Right? Does that mean that my 64 bit CentOS doesn't need it for that?

No, the theory bit just explains how it works, i.e. what goes into generating the unique ID. Namely: 32-bit IP address, 32 bit pid, 32 bit time stamp, 16 bit counter, 32 bit thread index. These are encoded to produce a 24-character string that, in properly configured clusters, should always be unique across all servers.

If enabled, the ID is generated for each request Apache processes, and stored in the $_SERVER['UNIQUE_ID'] environment variable [httpd.apache.org].

csdude55

11:10 pm on Nov 29, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I gotcha. So I guess I'm still kinda floundering on whether I should leave it enabled or not? I'm not finding a clear answer of, "if you turn it off then THIS might happen".

It's enabled by default so I guess that either Apache or cPanel recommend it? But it also says that using it causes a noticeable performance loss, so I would love to turn it off if it's not really critical.

I know that none of the programs I've written use it; at least, not intentionally. A Perl module or something might use it without my knowledge, but I've never consciously written anything to use the $_SERVER['UNIQUE_ID'] variable.

Some of my clients use Wordpress or Joomla, but I don't know if any of them use it.

And, of course, CentOS or cPanel might use it without my knowledge.

At this point it's just a guessing game. I would normally try turning it off and see what happens, but if the server needs it then I risk having a future problem that only happens under just the right (wrong?) circumstances; like from the example they gave, a duplicate PID.

csdude55

11:10 pm on Nov 29, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My whole goal here, though, is to see if I can shave 300ms off of each page load...

robzilla

11:49 pm on Nov 29, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's not really a guessing game if you look at the limited use case. I'd disable it, but wouldn't expect any major performance benefits.

As I noted earlier, since $_SERVER['UNIQUE_ID'] is specific to Apache's mod_unique_id, anything that relies on that variable would also require Apache.

like from the example they gave, a duplicate PID

This is described as a potential problem in generating a unique ID, not in generating an ID. You cannot have a duplicate PID on a single server, only in a cluster where each server will have its own PID's, which may coincide with the PID's of other servers. If you're not running a cluster of Apache servers, all of this doesn't really apply to you.

Profile your server-side scripting to find out what you can actually shave off your page load time.

csdude55

12:25 am on Nov 30, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As I removed it, I see that EasyApache 4 is also removing mod_security2. I'm not sure how I feel about that; it's also noted to affect performance, and since I use ConfigServer Firewall then it may not be necessary, anyway. I guess I'll find out! LOL