Load on the server

Discussions related to the 1.36.x series of ZoneMinder
sergmx
Posts: 36
Joined: Thu Jun 17, 2021 3:48 am

Load on the server

Post by sergmx »

I use the version 1.36.4

Cameras are recorded in mp4 through and look in the browser in edit(montage) mode. Video analysis is disabled.
When the stream was 1fps, the load on the server was insignificant and everything was fine. After increasing the frame rate to 8, the load on the server increased significantly and the montage mode practically stopped working.

How to optimize the load on the server or it can only be corrected by hardware increase of the server itself?
Attachments
Снимок экрана от 2021-07-13 07-57-21.jpg
Снимок экрана от 2021-07-13 07-57-21.jpg (59.18 KiB) Viewed 34923 times
ergamus
Posts: 27
Joined: Sat May 29, 2021 10:09 am

Re: Load on the server

Post by ergamus »

sergmx wrote: Tue Jul 13, 2021 4:05 am I use the version 1.36.4

Cameras are recorded in mp4 through and look in the browser in edit(montage) mode. Video analysis is disabled.
When the stream was 1fps, the load on the server was insignificant and everything was fine. After increasing the frame rate to 8, the load on the server increased significantly and the montage mode practically stopped working.

How to optimize the load on the server or it can only be corrected by hardware increase of the server itself?
How many cameras, what resolution/bitrate/profile level? Are you doing pass-through or transcoding in Zoneminder?

Montage mode takes the incoming stream from the buffer (assuming, since it makes the most sense), converts it into the format specified in the ZM config and sends it to your browser. So if you're using MJPEG for live streaming, for example 10 cameras @ 8 FPS that means 80 H.264/.265 frames being decoded/transcoded into MJPEG format per second. Going from 1 to 8 frames doesn't seem like a lot, but it means a drastic increase in CPU load for that workload. Keep in mind with that many cameras, you're might be pushing 100mbit/s+ to view that depending on your settings. As an alternative, try using Montage Review, which by default sends 1 frame per second per camera to the browser. Or by grouping your cameras so you're viewing 2/4 cameras at once instead of 10/20/x. Alternatively, reduce the quality of your montage stream. (see Option-Images or trying to introduce different transcode settings if you're pushing something other than MJPEG to the browser.)

Or try attacking the issue from the opposite direction, reducing bitrate/profile level on your cameras to make decoding easier. If your cameras are sending video with a 24bit color space, try setting the ZM camera settings to use 24 bit colors instead of 32 bit. I'd investigate if this reduces load, since it's possible the code for your platform is more optimized for handling 32bit pixels than 24.

You need to factor in your HTTP server now handling more requests per seconds to push those extra frames to your web clients. Every 100 frames is written as a bulk frame entry into the DB, maybe increase that value in the options as well if you see DB CPU usage spiking.

I'd make a wild guess that 1# user of CPU time is ZMC processes, followed by httpd/nginx/etc, followed by MySQL/MariaDB/etc.

It's possible Montage mode is choking because of CPU contention, network bandwidth, or because all the web server workers are busy with requests and can't keep up. Try to figure out where the bottlenecks might be.

What are your hardware specs?
User avatar
iconnor
Posts: 2900
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Load on the server

Post by iconnor »

Also, upgrade to 1.36.5. There are actual improvements in it.
sergmx
Posts: 36
Joined: Thu Jun 17, 2021 3:48 am

Re: Load on the server

Post by sergmx »

iconnor wrote: Wed Jul 14, 2021 2:48 am Also, upgrade to 1.36.5. There are actual improvements in it.
Thank you for your reply.
I did that, it didn't seem to help much. To make it work, I have now lowered the frequency from 8 to 2. It seems to work ...
Last edited by sergmx on Wed Jul 14, 2021 6:54 am, edited 1 time in total.
sergmx
Posts: 36
Joined: Thu Jun 17, 2021 3:48 am

Re: Load on the server

Post by sergmx »

ergamus wrote: Tue Jul 13, 2021 4:16 pm ...
How many cameras, what resolution/bitrate/profile level? Are you doing pass-through or transcoding in Zoneminder?
...
What are your hardware specs?
Thank you for your reply.

12 AXIS (different) camers
resolution from 640 x 480 to 1600 x 1200 (maximum for each camers)
Except 2 cameras firmware version 5 and I shoot the stream : rtsp://user:xxxx@192.168.xx.xx:554/axis-media/media.amp?videocodec=h264&streamprofile=Quality
By setting the right fps in the camera profile themselves.
pass-through - I think it will be less load on the server in recording mode.

Hardware: AMD Athlon(tm) II X2 270 Processor, Mem: 6G

Thank you very much for the advice I will try and figure it out, but I think the main load when decoding video when the client in the browser.
(The client is another computer)

Here is a picture of when I first set it to 1 frame per second when recording a stream.
(event - hour - day : from ALL camers)

P.S.
If your cameras are sending video with a 24bit color space, try setting the ZM camera settings to use 24 bit colors instead of 32 bit. I'd investigate if this reduces load, since it's possible the code for your platform is more optimized for handling 32bit pixels than 24.
Sorry, I read the documentation of the cameras and did not understand what color space they use
Attachments
Снимок экрана от 2021-07-12 13-55-31.jpg
Снимок экрана от 2021-07-12 13-55-31.jpg (4.37 KiB) Viewed 34857 times
sergmx
Posts: 36
Joined: Thu Jun 17, 2021 3:48 am

Re: Load on the server

Post by sergmx »

Excuse me, can I specify 2 sources per camera in the program?
The first source to record a direct stream of mp4, the second source in mjpeg to view the cameras in montage mode (without recording)?
I think that THIS will greatly reduce the load on the server.
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Load on the server

Post by Magic919 »

You can have multiple monitors that point to the same camera.
-
sergmx
Posts: 36
Joined: Thu Jun 17, 2021 3:48 am

Re: Load on the server

Post by sergmx »

I'm sorry, I must have misunderstood something.
I need 2 sources (2 streams, rstp mp4 for recording, and mjpeg for viewing in montage mode) to be bound to 1 monitor.

Are you talking about this ?
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Load on the server

Post by Magic919 »

You can’t do that.
-
sergmx
Posts: 36
Joined: Thu Jun 17, 2021 3:48 am

Re: Load on the server

Post by sergmx »

(Sorry for my English.)

I changed the server to a more powerful hardware, but the problem did not go away.
AMD FX(tm)-8320 Eight-Core Processor
RAM 8G
NVIDIA Corporation GP108 [GeForce GT 1030]
zoneminder 1.36.5

To save bandwidth from cameras and storage space, I record RTSP stream in mp4, and like everything is fine and the load is not much, although I put a frame per second. But as soon as you start viewing in montage mode, all these cameras through firefox, it is very heavy load.
---
08:11:56 up 1 day, 33 min, 2 users, load average: 2,58, 1,97, 2,37
Attachments
Снимок экрана от 2021-11-03 09-35-54.png
Снимок экрана от 2021-11-03 09-35-54.png (59.43 KiB) Viewed 33011 times
moholstein
Posts: 5
Joined: Fri Nov 12, 2021 1:57 pm

Re: Load on the server

Post by moholstein »

>analysis is disabled
why are you using zonminder in the first place?
you can use use ffmpeg directly .. to record the streams or make the montage.
>8 cores
>load of 3

8 cores means load of 16 is just busy enough to keep up.
try turning off hwacel options first .. then make sure your are using "cuda" leave 2nd part blank.

nvi utilities show the kernel recognizing the card? Ubuntu had some opopsies here.
If you really know what you're doing go get the IntelOne compiler (free for personal) and the whole CUDA caboodle and compile ffmpeg libjpeg-turbo and zoneminder from source with all 15 feet of options. This was the only way I got the 7 year old i5 to do this ... plus a cheap zotac card tha's a gtx630 so 192cuda. The Intel compile makes a ~15-20% difference across the board compared to GCC (unless youra gentoo kind of chap and are wait until next week on optimizations in GCC). Have the NVidia CUDA libraries and compiler as in from nvidia not the sort-of from free or non-free .. I mean go to nvidia and download it.

Don't go getting picky there. Use ubuntu like it says. Yes debian works. So should I have een.

I gave up long ago trying to get zomeminder to do a montage and for an eg : 1920x1080 TV where you want to stream it to a Roku/Fire stick or whatever it's easier to just pull 16 cameras into ffmpeg and generate a composite montage via a single RTP stream that resizes them to 320x240 in the process. That you can easily do, particularly if you have a decent nvidia and did he whole toolstack caboodle .. which if you do, you can run 16 cams through a $99 Jetson at 4mp.

I do 24 cams at 1280x1024 15fp/30fp keyframe in H264b CBR at 3072 and that vlan hums along at 80mbps just fine all day. 3rd get (Sandy Bridge) 4c/8t and 16gb of ram and I do ~50 zones. Note if you are doing vaapi (inel) and more than 2048 wide it's not supported, bear in mind that h264 at 1FPS is basically JPEG. The advantage of video codecs is they send only the pixels that change (a keyframe is a full image typically). So you're not compressing anything, your eating up more memory actually at 1FPS if your keyframe is set to eg: 10 as it has to buffer all that.

If the objective here is to best-of-both setup the alt steam on the camera to do black/white at CIF (320x240) and do frames with analysis no video and do your motion there, link it to parent cam as trigger, and make your montage out of the little guys. Nearly every cam vendor has a 2nd stream.
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Load on the server

Post by Magic919 »

If H264 at 1 fps is ‘basically JPEG’ there would be no need for the server to eat up memory buffering all 10 frames until the next key frame. Only where the camera doesn’t honour the set key frame interval for low fps would this hold true.

The rest is some good advice on dealing with server load.
-
sergmx
Posts: 36
Joined: Thu Jun 17, 2021 3:48 am

Re: Load on the server

Post by sergmx »

Thank you very much for your answers !

I am using : CentOS 7.9 + update today.

I have 11 old cameras AXIS :
2 - 800x600
2 - 1280x800
2- 1280x720
1 - 1280x960
4 - 1920x1080
To reduce the load on the server and disk I immediately record the stream in mp4 (ffmpeg)

But the same computer is also used for live viewing in MONTAGE mode. And as I understand firefox is very CPU intensive when it shows all these cameras in montage mode.

The video itself takes up very little space and I would be happy to increase the frames per second, but as soon as I do that the load increases even more.

I have seen cheap video recorders they record without problems 12 cameras in 1280-mp4 with frame rate 25....
And when you attach the monitor to this recorder everything runs smoothly ...
(example : https://www.dahua.market/videoregistrat ... r5216-4ks2)
It's Linux, too.I don't understand where the loss should be, why cheaper hardware is better at it.

Sorry I didn't quite understand the answer. Ie I need to have 22 cameras, 11 to record in mp4 and with the same 11 other streams only view in mjpg ?

Example one camera:
-------------------------------
Main
-----
Name: Monitor-1
Server: None
Source: Ffmpeg
Function: Mocord
Analysis Enabled: None
...
Source:
rtsp://192.168.1.10:554/axis-media/media.amp?videocodec=h264&streamprofile=Quality
TCP
32 bit
1280x960
...
Storage:
...
Save JPEGs: Disabled
Video Writer: Camera Passthrought
crf=23
...
-----------------------------------------

P.S.
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.63.01 Driver Version: 470.63.01 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A |
| 31% 35C P0 N/A / 30W | 611MiB / 2000MiB | 9% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1273 G /usr/bin/X 239MiB |
| 0 N/A N/A 2698 G /usr/bin/gnome-shell 23MiB |
| 0 N/A N/A 3506 G /usr/lib64/firefox/firefox 344MiB |
+-----------------------------------------------------------------------------+
sergmx
Posts: 36
Joined: Thu Jun 17, 2021 3:48 am

Re: Load on the server

Post by sergmx »

I have read a lot of information about this and would like to know how the editing mode works when recording the stream from cameras in mp4.

In general, I would like to be able to take 2 streams from each camera in future versions of the program. For good resolution for recording and bad resolution only for viewing and only in MONTAGE mode.
User avatar
kitkat
Posts: 193
Joined: Sun Jan 27, 2019 5:17 pm

Re: Load on the server

Post by kitkat »

sergmx wrote: Fri Nov 19, 2021 8:14 am In general, I would like to be able to take 2 streams from each camera in future versions of the program. For good resolution for recording and bad resolution only for viewing and only in MONTAGE mode.
I think you can do this to some extent.

Set up a monitor pointing to the camera's high-res stream and set it to Record.

Set up a second monitor pointing to the low-res stream and set it to Monitor.

When you view the Montage you'll see both streams but if you click the Function selector drop-down at the top of the page and choose Monitor you'll only see the low-res monitor.

The Function option is sticky so when you switch back to the console you'll only see the low-res monitor until you deselect it.

I guess you could probably even set the Function to Monitor before switching to Montage and avoid the initial load of de/recoding and sending both streams.
Post Reply