Seji64 / SniDust

SmartDNS Proxy to hide your GeoLocation. Based on DnsDist and nginx
GNU General Public License v3.0
149 stars 40 forks source link

Excessive usage of cpu #68

Closed meower1 closed 1 month ago

meower1 commented 2 months ago

Hi, so i've setup the project on my private server with the following specs

OS: Ubuntu 22.04.4 LTS x86_64
CPU: AMD Ryzen 9 7950X3D (2) @ 4.191GHz
Memory: 2133MiB / 5890MiB ddr5

and snidust seems to be consuming an unreasonable amount of resources specially cpu. it happens after a period of time has passed which im unsure of.

heres the output of docker stats

8b55bbbe447b   sniDust            160.70%   14.34MiB / 5.752GiB   0.24%     22.2GB / 22.1GB   28.6MB / 21.7MB   25

there is currently no user on the dns server other than myself

output of docker logs snidust

[INFO] [SniDust] Adding domain yallo.tv to list
[INFO] [SniDust] *** End of Domain List ***
[INFO] [SniDust] *** Complete! ***
Added downstream server 8.8.8.8:853
Added downstream server 8.8.4.4:853
Added downstream server 1.1.1.1:443
Added downstream server 1.0.0.1:443
Listening on 0.0.0.0:5300
ACL allowing queries from: 0.0.0.0/0
Console ACL allowing connections from: 127.0.0.0/8, ::1/128
Marking downstream cloudflare-dns (1.0.0.1:443) as 'up'
Marking downstream cloudflare-dns (1.1.1.1:443) as 'up'
Marking downstream dns.google (8.8.4.4:853) as 'up'
Marking downstream dns.google (8.8.8.8:853) as 'up'
===================================================================
[INFO] SniDust started => Using server_ip - Point your DNS settings to this address
===================================================================

my docker compose file:

version: '3.8'
services:
    seji64:
        container_name: sniDust
        environment:
            - 'ALLOWED_CLIENTS=0.0.0.0/0'
            - 'EXTERNAL_IP=server_ip'
            - 'SPOOF_ALL_DOMAINS=true' # Set to true (case sensitive!) if you want to spoof ALL domains.

            - TZ=Europe/Berlin
        ports:
            - '443:8443'
            - '80:8080'
            - '53:5300/udp'
            - '53:5300/tcp'
        image: 'ghcr.io/seji64/snidust:main'
        restart: on-failure:5

this has been the case for a while and had happened to me a bunch of time with this project i didn't have the time to report it tho.

thanks for the amazing project tho hoping to see this fixed in the future <3

Seji64 commented 2 months ago

could you run htop or something to track down the procress?

meower1 commented 2 months ago
image

this is htop's results filtered to "snidust". the cpu pressure hasn't began yet as i've just started the process and it often starts a few hours after execution

Seji64 commented 2 months ago

okay sorry, instructions were a bit unclear....i meant to run htop or similar inside container when the cpu usage is that high

meower1 commented 2 months ago

yeah i'll try to replicate the behavior on a spare server

meower1 commented 1 month ago

image this is the top results from within the container after about a week of having the container running

image output of docker stats

image and this is the top results from the first day i ran the container

image

output of htop outside of the container on the host machine

so in short the first few days i've ran it i've had no issues with it whatsoever and it ran normally consuming a reasonable amount of resources and it gradually increases the resource usage after a while. restarting the container temporarily solves the issue

Seji64 commented 1 month ago

so it seems to be a nginx thing. i applied some changes....(no clue if it helps or make things worse to be honest)

However, i guess if my general use config is not working / scaling for your amout of traffic, you should link your own which optimized for your hardware

meower1 commented 1 month ago

no worries ill test the new update and post the results here.

you should link your own which optimized for your hardware

im not sure i understand could u clarify this

Seji64 commented 1 month ago

i mean for example you need to set the nginx workers from auto to 16

In this case you can just link your own optimized nginx config:

version: '3.3'
services:
    snidust:
        container_name: snidust
        environment:
            - 'ALLOWED_CLIENTS=127.0.0.1, 10.111.123.7'
            - EXTERNAL_IP=10.111.123.8
        ports:
            - '443:8443'
            - '80:8080'
            - '53:5300/udp'
        volumes:
            - '~/mysuperchargednginx.conf:/etc/nginx/nginx.conf:ro
        image: 'ghcr.io/seji64/snidust:1.0.14'
meower1 commented 1 month ago

Hi again, I've been running the container for about a week and the performance issue seems to have been fixed. Thanks for the awesome project and the quick fix 🙌 ❤️

image