On 01/22/20 05:46 pm, Massimo S. wrote:
>
>
> Il 22/01/2020 22:59, Lewis G Rosenthal ha scritto:
>> On 01/21/20 04:52 pm, Massimo S. wrote:
>>>
>>>
>>> Il 21/01/2020 22:46, Massimo S. ha scritto:
>>>>
>>>>
>>>> Il 20/01/2020 10:54, Massimo S. ha scritto:
>>>>> Hi all,
>>>>>
>>>>> in the last months (since the end of october 2019) i've a number of hangs
>>>>> of the web server due to attacks (ddos or other) that comes on apache.
>>>>>
>>
<snip>
Suggestion #1: comment any modules you don't need. I doubt that you need
*all* those auth modules (authz_groupfile? really?). Do you really need
echo? usertrack consumes considerable overhead. Do you really track your
users via cookies? If not, you don't need this module.
>> or anything else, let alone what the server is serving. PHP is likely the
>> biggest drag on the system,
>
> i know this i've used apache with only html websites without php
> and it's rock solid stable
>
All well and good. When using php as module, there is a considerable amount
of interaction between httpd and php resources (php is loaded *all the
time*). You need to balance http performance against php performance
(sometimes), and you have to remember that you are essentially sharing
resources between the two environments (shared memory resources, that is).
>> and that's a whole other set of configurations (php.ini and the settings
>> for the PHP apps themselves).
>
> php.ini (resource limit part)
>
> max_execution_time = 180
> max_input_time = 600
> max_input_time = 180
> memory_limit = 256M
>
As Waldo has rightly point out, you have duplicate entries here. php.ini is
read and processed top down, so the last setting takes precedence. That
said, a production value for max_input_time is 60 seconds, not 10(!) or even
3 minutes (holy cow!), and production setting for max_execution_time is 30
seconds, not 3 minutes. the longer your php connections remain open, the
more you expose the server to getting "stuck." These aren't attacks, but
just lingering connections which shouldn't be left that way. Most PHP code -
for better or worse - leaves this up to the server setting (or
application-specific setting) to address.
memory_limit at 256M is fine (I used to be able to run at a fraction of this
value, but PHP hackers - not malicious hackers or crackers, but people
writing PHP scripts - being what they are, much code has just gotten sloppy
in recent years, requiring more memory due to shoddy practices). Still, it;s
nice to be able to keep this low overall and just set it higher in the
config for specific apps which require it.
<snip>
>>>> about MPM_MPMT
>>>>
>>>> i have:
>>>>
>>>> MinSpareThreads 29
>>>> MaxSpareThreads 33
>>>>
>>>> but i see this:
>>>>
>>>> P-ID PPID Session Thr Prio CPU Time Name
>>>
>>>> after some time..
>>>>
>>>> 3790 3785 020 VIO 36 0200 0:00:04.65 HTTPD.EXE
>>>>
>>>> where 3, 35, 33 and 34 are threads, is this normal?
>>>>
>>>> thanks
>>>>
>>>> massimo
>>>>
>>>
>>> where 36, 35, 33 and 34 are threads
>>> sorry the typo and the bad copy&paste
>>>
>>
>> No idea. How would I know, I wonder?
>
> it sound to me strange as MaxSpareThreads were 33
> and the threads of the childs show 36..
>
3 threads in use and 33 spares were available. The point of setting min/max
values is that these are created and idle (the min value) at daemon start
and will be added (put to use and the number of spares possibly increased)
as demanded. The numbers should bounce between the in-use threads + MinSpare
and in-use + MaxSpare.
>> As posted a gazillion times on this list already:
>>
>> <IfModule mpm_mpmt_os2_module>
>> ThreadStackSize 262144
>> StartServers 3
>> MinSpareThreads 50
>> MaxSpareThreads 60
>> MaxRequestsPerChild 1000
>> </IfModule>
>>
>> Been that way for ages. If your min/max values are too close, the server
>> will labor to constantly adjust the amount of spare threads. Note I said
>> *spare* threads, as in, idle threads available for work but which are
>> *not* in use. Without knowing what your overall thread count
>
> There are 32 Processes with 305 Threads.
> This machine's uptime is 0d 2h 40m 25s 949ms.
>
You need to monitor your threads over time to see what happens to this
value. Also, 2 hours is a vry short time to get an impression. Check it at
random intervals or when the system seems to be loaded and over a few days
of uptime. That should give you a better picture.
> apache:
>
> P-ID PPID Session Thr Prio CPU Time Name
>
> 4440 16 020 VIO 1 0200 0:00:05.12 HTTPD.EXE
> 4974 4440 020 VIO 36 0200 0:00:02.31 HTTPD.EXE
> 4973 4440 020 VIO 36 0200 0:00:07.87 HTTPD.EXE
> 4972 4440 020 VIO 34 0200 0:00:06.90 HTTPD.EXE
> 4971 4440 020 VIO 33 0200 0:00:06.75 HTTPD.EXE
>
>
>> is in the box, your THREADS= in CONFIG.SYS, how could anyone possibly
>> know whether your thread settings for the MPM are sane?
>
> threads in config.sys are
>
> THREADS=1024
>
> i've the same value on my 2 server, but also on the new AOS 503 on the
> test virtual machine that in the next monts will handle only apache+php
> i've seen that AOS put this value as default
>
Yes, it's a sane default figure. For a server, I wouldn't recommend anything
lower.
> other values in httpd.conf that may be of interested are set to:
>
> Timeout 60
> KeepAlive On
> MaxKeepAliveRequests 45
> KeepAliveTimeout 5
>
I would cut timeout to 30 (again, the longer you sit around waiting, the
more resources you're going to waste in the process). In the days of 56Kbps
connections, longer timeouts were necessary; today, not so much.
MaxKeepAliveRequests should be a higher value (Apache docs recommend 500 or
so; I use 500). The server will labor when this is set lower, as connections
will have to be reestablished. Reestablishing a connection is an expensive
proposition. There are conflicting user reports about this, with some
recommending very low values. I've *never* had good luck on OS/2 with this
set low (on NetWare, I've not found it to make much difference; again, it
all depends upon the memory model and how expensive these operations are on
a given platform).
KeepAliveTimeout 5 is a reasonable number. I would *not* recommend setting
this higher.
>
> about MinSpareTd and MaxSpareTd i've right now modified the apache
> configuration and now i have:
>
> <IfModule mpm_mpmt_os2_module>
> StartServers 4
> MinSpareThreads 29
> MaxSpareThreads 39
> MaxRequestsPerChild 95
> </IfModule>
>
>
> ..ThreadStackSize 262144
> what this value?
> i don't know much about this function is this value the one to use on
> mpmt_os2 or is a generic one?
>
If you are *not* getting crashes with Apache blowing the stack, you probably
don't need to adjust this. Various MPMs use this directive to set the stack
size allocated for each worker thread. The default on OS/2 is (still, IIRC)
65536 (see:
https://mantis.smedley.id.au/view.php?id=558 and
https://mantis.smedley.id.au/view.php?id=637 for more).
(That second link contains a lot of research and testing we did back in
2014/2015.)
>> Sorry to sound out of sorts, here, but please do some research on these
>> values and what they
>
> i've read and tried a lot in the past
> in the latest years that web server was more stable than in the last months
> after october 2019 i've seen an increase in the number of DDOS attacks
> and that kept the server more unstable (or at least i suppose this)
>
We all go through rough periods, and stopping all bad traffic is simply not
possible, even with the best firewalls. Still, not everything which appears
to be a DOS is really a DOS. Your server may be busy enough with something
else that clients get impatient and connections start piling up. It's a
balancing act, always, and it gets more difficult every year.
>> mean before suspecting anything is wrong. If you feel that the server
>> performance is off, switch back to defaults and start tuning again. How
>> you tune depends upon what you're serving. In fact, how you have your SSL
>> configured makes a big difference as well, as there is a significant
>> amount of overhead which may be generated when establishing connections.
>> There is no magic pill for all of this.
>
> slowly i'm moving websites to https
>
Best recommendation:
https://www.ssllabs.com/ssltest/
Test your server at the above. While you're there, try testing
www.arcanoae.com or
www.2rosenthals.com (A+ on both of those). Don't
discount the server load for poor SSL configuration.
Full disclosure: I own stock in Qualys. The above test is completely free,
however, and Qualys does not use the
ssllabs.com site to solicit business.
There is a lot of good information in the Qualys blog, too (though I miss
Ivan Ristić there; he's quite a wealth of information and has gone on to
form Hardenize:
https://www.hardenize.com).
> thanks a lot for the help
>
You bet.