[RESOLVED] Sometimes slow on Gladys Plus dashboard

Hello,

I have a display issue on the dashboard below that occurs regularly when I go through Gladys Plus. I first thought this happened when the Raspberry did not reboot for several weeks. I therefore scheduled a weekly reboot but it quickly came back. My other hypothesis would be the slowness of my internet connection. Would other users have this problem?

The two boxes on the right are supposed to display my cameras. The image eventually arrives a few dozen seconds later but the error message remains present.

Hello @Mastho, that’s strange! Indeed, it might be an internet connection issue, but not necessarily.

To better understand your problem:

  • Which Raspberry Pi do you have? Connected to a high-performance micro-SD (or not?)
  • Could you post a speed test here (on the Raspberry Pi at your place AND on the machine where you use Gladys Plus)?
  • How many cameras do you have on your installation? Do you feel like your local Pi is « under pressure » or is it not too busy? What refresh rate have you set for the cameras?

We’ll debug this together until we figure it out :smiley: If you’re available, we can also call directly to see it live together.

Thanks again for your support via Gladys Plus :pray:

Hello @pierre-gilles,

I have a 3B+ that I bought almost 2 years ago with a 24 Mb/s micro-SD.
I don’t think it’s a performance issue because locally, the display is instantaneous for the 4 boxes I currently use on the dashboard. I only have these two cameras with a refresh every minute.

Via Gladys Plus, I have the same problem whether I’m at home or on 4G from my phone. In the Gladys settings, I have a latency of 66 ms locally and 1500 ms via Gladys Plus.

I should have a time slot on Saturday or Sunday if you’re available too.

Below is the speedtest. For the internet box, I have 16 Mbit/s down for 900 kbit/s up.

Ouch, are you on ADSL for your internet box? With which operator?

You do have a fairly low upload speed, and a really high ping, which explains the slowness you’re experiencing, but that doesn’t explain everything. Normally, it should just be slower.

Available this weekend whenever you want to look at it together.

I’ll contact you in private message.

Attention local server located in Barcelona

@Mastho lives in the south of France, that makes sense :slight_smile:

So I never really checked, what is the « average ping » via Gladys Plus?
I have 267ms on 4G+, it seems like a lot to me (60 locally).

Fiber + 1Gb/s LAN + Dual Xeon server, doesn’t seem like there’s a bottleneck at my end.

267ms is excellent, you have nothing to blame yourself for :smiley:

Actually, the word « ping » might be misused here, it’s not just network time here, but processing time in this calculation.

What is calculated is the time between:

→ The frontend sends « ping » to the Gladys Plus server
→ Gladys Plus sends « ping » to your Gladys instance
→ Your Gladys instance responds « pong » to the Gladys Plus server
→ Gladys Plus responds « pong » to the browser

So in fact, the « ping » is more like a « ping x4 » here, knowing that at each step there can be simple delays (your Gladys instance is requested by sensors permanently, so it may not respond pong directly, etc..).

267ms for you is just excellent for all that :slight_smile:

You have 60ms because the ping is just a « ping » to your machine on the local network.

ADSL with Sosh. But it still has a significant latency for a few pings, even on ADSL.

I’ll show you all that and we’ll do some tests :slight_smile:

We just had a call with @Mastho to investigate, and it’s not a network issue, but rather a local problem on his Gladys instance :slight_smile: This is good news, as there’s nothing we can do about network issues, but a local problem can be resolved!

Looking at his logs, we saw a lot of « DATABASE_IS_LOCKED SQLITE_BUSY » at the location insertion level, and in my opinion, this comes from the transaction here: Gladys/server/lib/location/location.create.js at master · GladysAssistant/Gladys · GitHub

What’s interesting is that after restarting Gladys, the problem was gone, and Gladys Plus was working fine.

The fact that we’re using a transaction can create a deadlock, and I wonder if that’s what’s happening here.

In my opinion, the transaction doesn’t necessarily make sense here, and we can remove it. Especially when Gladys is used on micro-SDs with rather average read/write performance, a transaction is heavy and queues all other writes (SQLite in WAL mode only supports one write at a time).

This is exactly the same problem I was regularly having as well with

and the issue with the loss of Gladys Plus. Great if this can be resolved!!

@Terdious have you still had the problem since you switched to SSD?

Still having access issues yes!!



Yet I’m fine on this side

But no logs here:

Oh dear! Your logs don’t show anything particular (I see caldav, but everything seems to be fine), is this the correct screenshot?

Yes that’s the right one! So it’s as if he wasn’t even trying to connect!

Ok, I tested it locally, and indeed I found issues with the transactions we use. Clearly, there were bugs as soon as there was any concurrency. I wonder if the version of Sequelize we are using also has problems with this. We will need to consider updating Sequelize…

I made a PR that removes these faulty transactions and adds concurrency tests, and now it works much better:

New:


I have nothing left even though the cursor is good locally ^^
No way to return to the login page from here ^^

Hello,

A quick update from my side:

  • Installation of Gladys on a Raspberry (with the installation you provide), no service is configured
  • Configuration of Gladys Plus

I have fiber, Raspberry Pi 4 with an SSD (OK on USB2 but still). I have pings at 600ms … No database is locked. Not sure that’s it. :confused:

Super weird, I’ll try to push the fix later today!

I don’t see the problem, that’s a good number :slight_smile: As explained earlier, it’s not a ping!

If this number stresses everyone out, I’ll remove it, it seems to cause more problems than anything else ^^

@damalgos following our call this morning, I investigated, and you were right 600ms is not normal :smiley:

Already on the Gladys gateway server side, I made some optimizations, but they do not significantly change the situation.

The real problem comes from this famous « getUserById » local to Gladys, which makes a DB call for each request, and which can cause DB blockages. I noticed blockages of 700ms locally at my place, despite the fact that I am on a Mac with a future SSD…

This DB query is not necessary, by replacing it with a RAM call (thanks to the « stateManager »), I drop to 55ms, it’s much better, and it corresponds more to what we expect from a request.

Proof to support: (it’s not local)

For those who are interested, here are some stats of the time for each step of a request via Gladys Plus:

The line that was causing the problem was « getting-local-user », and now it takes 0.009ms, much more opti :ok_hand:

I continue my optimizations to see if we can’t go further.