petelacey

petelacey

The Phoenix/LiveView-based product that my company makes has a very unusual usage profile. For months at a time, any particular customer will make very light usage of it. Until, suddenly, 20, 50, or even 100 or more users will start pounding on the product at once. This will last for 1-3 weeks before going silent again. This is expected and not a big deal.

However, the industry we serve is such that when these, say, 50+ people are hammering away, they are physically together in the same room as they do so! Furthermore, our customers are not tech savvy and so they tend to all be connected to the same under-powered office WiFi access point.

If this was a normal web application, then that wouldn’t be a problem. But with LiveView I now have 50+ people sitting inches away from each other and trying to keep a persistent websocket connection in place, all while uploading/downloading gigabytes of data per day. The result is calls to our support line saying the product is slow, when in reality they have an oversaturated access point and probably a great deal of EM interference.

What I’d like to do in this situation is simply notify users that their connection is wobbly and provide a link to instructions on how they can mitigate this. I experimented with JavaScript’s navigator.connection property (Chrome only, but that’s okay) and that might be enough. But it didn’t seem to notice when I enabled the liveview socket’s enableLatencySim, and I’m not sure if it should have.

In any event, I’m wondering if anyone else has dealt with this and what solutions you have come up with?

Thanks, Pete

Showing Posts 1 to 8

arcanemachine

arcanemachine

This is a pretty hacky idea, but perhaps you could use Phoenix Presence to detect when a lot of users from the same organization or IP address are present at the same time, and just pre-emptively send a warning when a certain simultaneous user count is reached.

Obviously not the most practical idea, but if nothing comes up, it may be a workable (and easy-to-implement) solution.

olivermt

olivermt

If you have links to mitigate this, why not just… pre-mitigate? Or are these groupings dynamic in nature?

cheerfulstoic

cheerfulstoic

I’m not familiar with navigator.connection, but you could perhaps use Chrome’s throttling it it’s DevTools for something which is probably lower-level than what Phoenix/LiveView can simulate:

Also, have you done any optimization of your LiveView? Sometimes it does some annoyingly inefficient things when sending data over the wire. This presentation has some tips on how to help with that:

Also, they’ve been introducing some optimizations in newer versions of LiveView which take care of optimization in some cases with you having to do anything, so upgrading might help.

petelacey

petelacey OP

Unfortunately, the “mitigation” entails telling people to call IT and have them bring in some switches and ethernet cables. And, yeah, the groupings are dynamic and not known in advance.

petelacey

petelacey OP

There’s plenty of room for us to optimize LiveView, but I’m certain the problem would still exist. It’s really a matter of too many people transferring too much data over too many connections on a single AP. Exacerbated by many of those connections (though not the file upload/download ones) being persistent LiveView sockets.

krasenyp

krasenyp

I’d say it’s not the job of the server to notify the user if their connection is slow. It’s the job of the client. You should somehow observe the network requests and determine if they’re slow enough to notify the user.

Unfortunately, with LiveView running on a websocket, I don’t have any ideas how to do the above.

rhcarvalho

rhcarvalho

Not a definitive answer, but:

  • Some tips here: Simulate Latency, Jitter, and Package Loss in Phoenix LiveView
  • I also recall a talk in which Chris McCord demos a LiveView showing live latency to clients around the world, but I couldn’t find it now.
  • Probably the best integration points would be global code in app.js monitoring client network performance, or a client Hook. In the absence of a better idea, you can measure pings between client and server and use that to trigger adding a CSS class/JS command to show the message about contacting IT, etc.
namxam

namxam

Honestly, this sounds like a pretty feasible solution. It is rather easy to implement and you could simply configure the amount of connections before an info message appears, notifying the end user, that there are many connections from a single IP.

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews