Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU usage when idling if port mapping is enabled #2589

Closed
agilob opened this issue Mar 13, 2020 · 53 comments
Closed

High CPU usage when idling if port mapping is enabled #2589

agilob opened this issue Mar 13, 2020 · 53 comments
Labels
bug Something isn't working help wanted Extra attention is needed stale Stale and will be closed if no activity occurs

Comments

@agilob
Copy link

agilob commented Mar 13, 2020

Describe the bug
Since 10.5.0 jellyfin has higher CPU usage even when not being used.

System (please complete the following information):

  • OS: official docker
  • Virtualization: Docker
  • Clients: any or none
  • Jellyfin Version: 10.5.0
  • Installed Plugins: none
  • Reverse Proxy: traefik
  • Base URL: none
  • Networking: Host
  • Storage: local zfs
  • CPU: i7 mobile

To Reproduce

  1. Run jellyfin 10.5.0 - after upgrade from 10.4.x
  2. Observe docker stats
    https://gfycat.com/gravehelpfulconch

Expected behavior
When jellyfin isn't used, CPU usage should not be that high

Logs
Nothing is logged when CPU has high usage and no client is using jellyfin

@agilob agilob added the bug Something isn't working label Mar 13, 2020
@YouKnowBlom
Copy link
Contributor

Anything in the logs? Could be background tasks, thumbnail image extraction, etc

@agilob
Copy link
Author

agilob commented Mar 13, 2020

CPU usage has been on that level since upgrade, that's a few days now as I was early adopter and helped with testing of 10.5.0. Logs are pretty much empty, no scanning is going on in background.

docker logs jellyfin --follow shows only past started playbacks and warnings about broken websockets from yesterday and today:

[10:39:07] [ERR] [36] App: AcceptWebSocketAsync error
System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
 ---> System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
   at System.Net.WebSockets.ManagedWebSocket.ThrowIfEOFUnexpected(Boolean throwOnPrematureClosure)
   at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken, Boolean throwOnPrematureClosure)
   at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TWebSocketReceiveResultGetter,TWebSocketReceiveResult](Memory`1 payloadBuffer, CancellationToken cancellationToken, TWebSocketReceiveResultGetter resultGetter)
   at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TWebSocketReceiveResultGetter,TWebSocketReceiveResult](Memory`1 payloadBuffer, CancellationToken cancellationToken, TWebSocketReceiveResultGetter resultGetter)
   at Emby.Server.Implementations.SocketSharp.WebSocketSharpListener.ProcessWebSocketRequest(HttpContext ctx)
[10:43:30] [ERR] [13] Emby.Server.Implementations.HttpServer.HttpListenerHost: Error processing request: A task was canceled.
[10:43:30] [ERR] [25] Emby.Server.Implementations.HttpServer.HttpListenerHost: Error processing request: The operation was canceled.
[10:43:30] [ERR] [13] Emby.Server.Implementations.HttpServer.HttpListenerHost: Error processing request: The operation was canceled.

@zedred79
Copy link

I have the same problem. Since I updated Jellyfin in idle state it consumes 10% of cpu. The time now is 18:49 and the last log is in the startup phase of the container at 18:16, there are no active processes yet, but the processor consumes 10%

[18:16:15] [INF] [1] App: Core startup complete [18:16:16] [INF] [9] LibraryMonitor: Watching directory /data/cartoon [18:16:16] [INF] [6] LibraryMonitor: Watching directory /data/film2 [18:16:16] [INF] [11] LibraryMonitor: Watching directory /data/movies [18:16:16] [INF] [11] LibraryMonitor: Watching directory /data/serie2 [18:16:16] [INF] [9] LibraryMonitor: Watching directory /data/tvshows [18:16:16] [INF] [10] LibraryMonitor: Watching directory /data/music [18:16:16] [INF] [1] App: Executed all post-startup entry points in 0:00:01.0497372 [18:16:16] [INF] [1] Main: Startup complete 0:00:10.2206823 [18:16:17] [INF] [9] TaskManager: StartupTrigger fired for task: Update Plugins [18:16:17] [INF] [9] TaskManager: Queueing task PluginUpdateTask [18:16:17] [INF] [20] TaskManager: Executing Update Plugins [18:16:20] [INF] [11] TaskManager: Update Plugins Completed after 0 minute(s) and 2 seconds [18:16:20] [INF] [11] TaskManager: ExecuteQueuedTasks

@goliath888
Copy link

Same here, my CPU is always between 10-15% even more in idle. I have OpenMediaVault and I am receiving all day al different times warnings that my cpu usage is been too high for too much time.
If I see anything relevant in the logs I will post it here.

@Lisuibiao
Copy link

Try to UNCHECK the "Networking->Allow remote connections to this Jellyfin Server " option, if you dont need the remote access or done it by nginx. Works for me.

@code-moritz
Copy link

code-moritz commented Mar 16, 2020

when the docker image upgrade to 10.5 version. the server has some problem.
i open the htop command line. and found the ffmpeg program comumeing much much more cpu resource. the cpu is in high perference.

but at that time, i am already stop plying and close the web client. but the ffmpeg decoding thread still running and using much CPU resource.

#system information#

  • hardware : Raspberry pi 4 4G RAM
  • OS : Raspberry OS (based on debian 10 buster 32bit)
  • Docker : the latest version
  • Jellyfin version : 10.5 ( download from hub.docker.com)

please reference the follow scrrem print.
ScreenPrint-1

ScreenPrint-2

@agilob
Copy link
Author

agilob commented Mar 16, 2020

Try to UNCHECK the "Networking->Allow remote connections to this Jellyfin Server " option, if you dont need the remote access or done it by nginx. Works for me.

Yes, this actually worked. CPU usage when idling went down to >0.2%

@goliath888
Copy link

ECK the "Networking->Allow remote connections to this Jellyfin Server " option, if you dont need the remote access or done it by nginx. Works for me.

That is the answer! Thanks

Just look at this:

image

@budimanjojo
Copy link

ECK the "Networking->Allow remote connections to this Jellyfin Server " option, if you dont need the remote access or done it by nginx. Works for me.

That is the answer! Thanks

Just look at this:

image

It works for me too, but now I can't connect to my jellyfin anymore outside of my network using domain name. It says "Forbidden". I'm using traefik as my reverse proxy too. Any idea?

@dkanada
Copy link
Member

dkanada commented Mar 29, 2020

Hmmmm this bug just became extremely interesting.

@budimanjojo
Copy link

So main culprit is the remote connection handling. But I checked Secure connection mode to handled by reverse proxy. So Jellyfin should do nothing and let the reverse proxy doing it's job (in my case Traefik). What is Jellyfin doing when handled by reverse proxy is checked?

@mark-monteiro
Copy link
Member

I've was working on documenting the networking options yesterday and I from what I can tell here are the two things that the 'allow remote connections' option controls:

  • EnableRemoteAccess
    • Used to enable/disable UPnP. For UPnP to be enabled, both the EnableUPnP and EnableRemoteAccess settings must be true
    • If true, turns on filtering of remote IP addresses using the whitelist/blacklist

It's possible, that UPnP is causing this, it does some work in the background on a timer. Maybe someone with this issue can try enabling remote access again, then setting EnableUPnP to false to check if this is the culprit.

@zedred79
Copy link

I've was working on documenting the networking options yesterday and I from what I can tell here are the two things that the 'allow remote connections' option controls:

  • EnableRemoteAccess

    • Used to enable/disable UPnP. For UPnP to be enabled, both the EnableUPnP and EnableRemoteAccess settings must be true
    • If true, turns on filtering of remote IP addresses using the whitelist/blacklist

It's possible, that UPnP is causing this, it does some work in the background on a timer. Maybe someone with this issue can try enabling remote access again, then setting EnableUPnP to false to check if this is the culprit.

It's work!!!
Thanks you

@budimanjojo
Copy link

I've was working on documenting the networking options yesterday and I from what I can tell here are the two things that the 'allow remote connections' option controls:

  • EnableRemoteAccess

    • Used to enable/disable UPnP. For UPnP to be enabled, both the EnableUPnP and EnableRemoteAccess settings must be true
    • If true, turns on filtering of remote IP addresses using the whitelist/blacklist

It's possible, that UPnP is causing this, it does some work in the background on a timer. Maybe someone with this issue can try enabling remote access again, then setting EnableUPnP to false to check if this is the culprit.

Wow it works.. Disabling enable automatic port mapping brings my idle cpu usage from 11% to 0.5%!

@JustAMan
Copy link
Contributor

JustAMan commented Apr 3, 2020

We really should default "automatic port mapping" to "disable". The concept itself is just so... wrong (not in JF, but in general in UPnP).

@JustAMan JustAMan changed the title High CPU usage when idling High CPU usage when idling if port mapping is enabled Apr 3, 2020
@sponix
Copy link

sponix commented May 4, 2020

Yeah, I had Jellyfin 10.5.5 doing similar. It would MAX one or sometimes even two cores on my CPU and just hold them there. Just disabling uPnP didn't do it for me, but keeping that off and also disabling all DLNA features did. Jellyfin is now using only about 100MB of Ram, and next to no CPU. So, I would highly recommend giving that a try for anyone that can live without them. Hmm, okay.. I was wrong, after a day or so it is back to maxing out 2 cores of my CPU all the time again.

@Forceflow
Copy link

Forceflow commented May 6, 2020

Can confirm that I've had this in jellyfin (docker), but my htop indicated the builtin ffmpeg was the one hogging 5-10% cpu constantly, which striked me as weird, because (A) I wasn't using the server at the time and (B) all image extraction / chapter image generation had been disabled.

Would have never thought this was UPNP related.

Disabling automatic port forwarding made the cpu usage go away.

Might be related (though not the same project, of course): Plex at one point had an issue with their builtin UPNP client hammering miniupnpd somewhere in the network, pegging one core at 100% constantly too.

@hardwareadictos
Copy link

Can confirm that I've had this in jellyfin (docker), but my htop indicated the builtin ffmpeg was the one hogging 5-10% cpu constantly, which striked me as weird, because (A) I wasn't using the server at the time and (B) all image extraction / chapter image generation had been disabled.

Would have never thought this was UPNP related.

Disabling automatic port forwarding made the cpu usage go away.

Might be related (though not the same project, of course): Plex at one point had an issue with their builtin UPNP client hammering miniupnpd somewhere in the network, pegging one core at 100% constantly too.

I have the same exact issue as you, but im unable to fix it by disabling remote conections

@hardwareadictos
Copy link

Also disabled all DLNA settings and automatic port mapping, anyone tried anything else? My Pi4 has always one core at 100% constantly when Jellyfin container is running, even if its idling with the ffmpeg process, Its only happening with 10.5.5

@Forceflow
Copy link

Forceflow commented Jun 15, 2020

Also disabled all DLNA settings and automatic port mapping, anyone tried anything else? My Pi4 has always one core at 100% constantly when Jellyfin container is running, even if its idling with the ffmpeg process, Its only happening with 10.5.5

Have you restarted jellyfin since changing that setting? That was necessary for me to resolve the issue. (JellyFin in Docker)

@hardwareadictos
Copy link

Also disabled all DLNA settings and automatic port mapping, anyone tried anything else? My Pi4 has always one core at 100% constantly when Jellyfin container is running, even if its idling with the ffmpeg process, Its only happening with 10.5.5

Have you restarted jellyfin since changing that setting? That was necessary for me to resolve the issue. (JellyFin in Docker)

I did and it solved the issue momentaneously. After some minutes it starts using one core intensively again.

@dufferzafar
Copy link

I can confirm this as well. Unchecking "Enable automatic port mapping" on the Network settings reduced CPU usage from around 10-15% to essentially 0%

@dkanada
Copy link
Member

dkanada commented Jun 16, 2020

So now we have some reports that this is the fix and one report that this is only a temporary fix, I wonder if there's some other variable at play here.

@hardwareadictos
Copy link

Okay, i can confirm that the only way for me to workaround this is to rollback to 10.4.X Releases...

@alpacalife
Copy link

Jellyfin 10.5.5 in docker on Ubuntu 20,04 host.

I am glad I found this issue. It was bugging me why I was seeing high load on this server the last couple times I was remoted in or using an app hosted on it. I actually just was messing around with different hardware and was dismissed to the new hardware.

My server load went from 12-13 to 0.2 when changing Enable automatic port mapping under Networking. Will monitor for changes.

@BaronGreenback
Copy link
Contributor

BaronGreenback commented Jul 2, 2020

PR #3339 and #3257 might help.

Jellyfin processes it's own SSDP multicasts. uPNP port mapping was also linked into SSDP detection causing a constant background processing loop.

It also doesn't handle any kind of network changes well.

@BaronGreenback
Copy link
Contributor

Is the cpu as the same level?

@BaronGreenback
Copy link
Contributor

Also if you enable debug logging for Mono.Nat or Mono.Nat.Searcher then it should show you if uPNP is the culprit as it now has logging.

@NearlCrews
Copy link

I just upgraded from 10.5.5 to 10.6.0 on Arch Linux. This is an actual install without Docker. CPU was constantly between 10-15% even when idle. I've got the following checked, which I'm 99% sure was the default:

Enable DLNA Play To: ENABLED
Enable DLNA server: ENABLED
Blast alive messages: ENABLED
Allow remote connections to this Jellyfin Server: ENABLED
Enable automatic port mapping: ENABLED

I changed Enable automatic port mapping to DISABLED and idle CPU usage dropped to almost zero.

@BaronGreenback
Copy link
Contributor

See above. The PR's are waiting for review and were not included in 10.6.

There's also an additional PR #3529 which filters the SSDP broadcast so should reduce processing.

I haven't been able to reproduce this problem at my end. Have you got many SSDP devices on your network?

@NearlCrews
Copy link

NearlCrews commented Jul 23, 2020

Have you got many SSDP devices on your network?

I just ran tcpdump to check. I've probably got about 60 IPs assigned on my network. The majority of the port 1900 traffic is between Jellyfin and my HDHomeRun. Broadcasts are basically non-existent, so not much in the way of SSDP broadcasts.

@BaronGreenback
Copy link
Contributor

@NearlCrews - are you able to do custom builds, and would be willing to try PR #3339?

As i haven't been able to reproduce this issue, i can't say it's a 100% guaranteed fix - but it does have detailed logging - so should be able to tell us what's happening even if it doesn't fix the issue.

@hardwareadictos
Copy link

Blast alive messages: ENABLED

I can confirm this behaviour as well.

@NearlCrews
Copy link

@BaronGreenback I can spin up a VM and give it a shot later. I don't have an easy way of doing it on my existing build. Let me take a look later today and I'll get back to you. Thanks again!

@bugsyb
Copy link

bugsyb commented Oct 23, 2020

I changed Enable automatic port mapping to DISABLED and idle CPU usage dropped to almost zero.

Can confirm this as well - Odroid N2 and Jellyfin doing nothing was at ~10% load all the time. Disabling automatic port mapping and it disappeared from top output (v 10.0.6.5.).

@MrAureliusR
Copy link

I changed Enable automatic port mapping to DISABLED and idle CPU usage dropped to almost zero.

Can confirm this as well - Odroid N2 and Jellyfin doing nothing was at ~10% load all the time. Disabling automatic port mapping and it disappeared from top output (v 10.0.6.5.).

Oh dear lord THANK YOU.
Jellyfin has been taking up 10-15% CPU usage since I installed it months ago. I just kind of assumed it was normal, but recently it's been nagging at me. It shouldn't take any usage when idle. This instantly fixed the issue.

@hardwareadictos
Copy link

Seems te issue came back on 10.7.1-1....

@cvium
Copy link
Member

cvium commented Mar 25, 2021

We haven't made any fixes for it. Are you saying that the issue was gone in 10.7.0?

@hardwareadictos
Copy link

We haven't made any fixes for it. Are you saying that the issue was gone in 10.7.0?

Yea, rolling back to 10.7.0 fixed the issue, probably is not dealing with DLNA

@agobernat
Copy link

I am also having this issue (on version 10.7.5). Just recently I had to cut the power to the server, because it sat at 400%cpu usage on a ryzen 2700x, and thus became unresponsive to ssh commands. At other times, it was using ~40% idle.

Disabling automatic port mapping and restarting seems to have fixed it for now.

@stale
Copy link

stale bot commented Oct 2, 2021

This issue has gone 120 days without comment. To avoid abandoned issues, it will be closed in 21 days if there are no new comments.
If you're the original submitter of this issue, please comment confirming if this issue still affects you in the latest release or nightlies, or close the issue if it has been fixed. If you're another user also affected by this bug, please comment confirming so. Either action will remove the stale label.
This bot exists to prevent issues from becoming stale and forgotten. Jellyfin is always moving forward, and bugs are often fixed as side effects of other changes. We therefore ask that bug report authors remain vigilant about their issues to ensure they are closed if fixed, or re-confirmed - perhaps with fresh logs or reproduction examples - regularly. If you have any questions you can reach us on Matrix or Social Media.

@stale stale bot added the stale Stale and will be closed if no activity occurs label Oct 2, 2021
@cvium cvium added the help wanted Extra attention is needed label Oct 5, 2021
@stale stale bot removed the stale Stale and will be closed if no activity occurs label Oct 5, 2021
@jesgp
Copy link

jesgp commented Nov 8, 2021

I believe this issue is still relevant - could replicate using Docker image (0aa773b67433), deactivating DLNA server fixed the issue.

@cvium
Copy link
Member

cvium commented Nov 8, 2021

None of us can replicate it though, so it's unlikely to be fixed

@sponix
Copy link

sponix commented Dec 6, 2021 via email

@Boblespam
Copy link

Checked my cpu usage today, around 10% idle, used method provided before :

"Networking->Allow remote connections to this Jellyfin Server " option : Uncheck

This is already done by nginx, still working. Now idle usage is around 0.01%. One of my lowest service, was the first one before...

Curious.

Thanks for the tips.

@cvium
Copy link
Member

cvium commented Jun 2, 2022

It would be helpful if you could all provide some more information about your systems (server, router, network etc.). I am still unable to replicate it.

@Boblespam
Copy link

Beginner here but will try my best :

System os : Open Media Vault 5
Jellyfin is running in a docker container, image is : lscr.io/linuxserver/jellyfin:latest (Image sha256:2376b37ff8278b82fb4adac36cd238aba6c1cf206d100433d3fdb2f8a1b686ca
)
Running in his default network, my router is provided by SFR NB6 nothing particular about it. No vlan, No ipv6 activated, only particular stuff is the port forwarding for nginx container and wireguard docker container.
Got an nginx proxy manager running but does seems to affect the cpu usage if I disable the whole configuration.

If you have more question, I will try my best to answer.

English is not my main language, I hope I'm understandable.

@jellyfin-bot
Copy link

This issue has gone 120 days without an update and will be closed within 21 days if there is no new activity. To prevent this issue from being closed, please confirm the issue has not already been fixed by providing updated examples or logs.

If you have any questions you can use one of several ways to contact us.

@jellyfin-bot jellyfin-bot added the stale Stale and will be closed if no activity occurs label Oct 24, 2023
@jellyfin-bot
Copy link

This issue was closed due to inactivity.

@jellyfin-bot jellyfin-bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed stale Stale and will be closed if no activity occurs
Projects
Archived in project
Development

No branches or pull requests