Is Wappler reactive?

I thought websockets kept a list of ‘listeners’, so when an update was made, they would notify the listeners. So no polling.

Maybe I’m wrong though.

ok…

  1. websocket
  2. data / dataset refresh (wappler events - wappler action scheduler)

sorry , I dont know different option :slight_smile:

Many thanks for your input.

You are welcome
Dont forget :slight_smile: wappler always coming much more good news every week …

Problem with using a third party websocket is that, if the database is updated directly, the websocket doesn’t know there’s been an update(as the update hasn’t gone through the websocket), so it can’t notify the listeners.

That’s why I think the websocket should be implemented within Wappler Server Connect. If there was option in the action (or query, I’m still new to Wappler) to open a websocket, then whenever there was an update to the data returned by that action (or query), Server Connect would notify the listeners.

Maybe @Georgeis right, and websockets still need to poll the data periodically to find out if there has been changes. I don’t know the internals of websockets to be honest.

Well the websockets does but the database have to trigger an update and most database don’t. So you have to have something else on the server polling the database constantly and then triggering all the websockets.

1 Like

Again, Action Scheduler is your friend. I have a table with over 12,000 job orders that I pull all Open job orders from into a table on one of my dashboards. I have a scheduler set for 2 seconds (could set it for 1 second if needed) and even if I update/add data through Navicat it updates the displayed data instantly.

1 Like

Doesn’t querying the database every 2 seconds put too much strain on the database?

Nope, nothing noticeable at all. And that is running on an old Windows 2007 (maybe it’s 2009) Server.

It also depends on how much traffic your site has :slight_smile:

If the polling is set to just check for updates in the table, I don’t think it will put any pressure no matter the traffic.
Once an update is found, only then the actual query would fire and get the conplete data.

In this case, the pressure would be on the web server, rather than the DB from what I understand.

I’m guessing the action scheduler runs the same query it run the first time to get the data.

If the query is complex, and the scheduler is running every 2 seconds, I’m concerned about putting too much strain on the database.

What kind of Database is it and do you have full control over it? For MS SQL you could write an CLR function that you call on in a trigger when the table is updated. In the CLR function you then call some server/api endpoint that manages the websocket connections and messages the clients of the update. For the realtime (websocket) communications (client and server) something like https://socket.io/ can be used.

There are also realtime databases like https://firebase.google.com/docs/database/.

It will not be easy to implement and Wappler doesn’t have the tools for it. Wappler can help you with building the front-end of your app/webpage, but the realtime server implementation is something that is currently outside the range of Wappler.

1 Like

Thats correct.

So what I am proposing is to use some other table which updates on trigger when data is updated on main table.
Then, poll the other table for changes… and when its value changes, call the actual query on the main table.

Firebase is indeed a good solution for realtime database with automatic data push.
We hope to integrate it in Wappler soon.

But just as any cloud database and service - you have to be really careful what you are doing, so that you don’t get a huge bill, like:

3 Likes

What about CouchDB with a Continuous feed?

http://guide.couchdb.org/draft/notifications.html

Around 2001 or so we run a gaming server provider and one of us (not mentioning any names) decided it would be a good idea to spawn servers based on a full load, so for instance when a TFC server hit 32 players spawn a new server, auto increment on the port ie from 27015 to 27016 etc, same for CS servers hitting a 12 player maximum spawn another server, all through a basic Bash script and a little hack here and there… We got the monthly invoice from the data center… HMMMMMMM… We were early adopters of 64 BIT Opterons from AMD and worked closely with them at the time, thankfully they stepped in and paid our bills! I can’t remember the exact amount but it was around £10k or so after the script spawned dozens of servers!

:smiley:

1 Like

All these cloud databases will cost alot.

All you need is one server and some knowledge and you will have real-time database.

2 Likes

Is this on the roadmap? FireStore integration would be awesome. TBH, at that point, you may as well integrate the rest of Firebase’s offerings - Cloud Functions, Cloud Storage etc. Now that would be amazing!

3 Likes

This is a really good thread. One quick question, though.

What is the resource implication of using the scheduler every second compared to every minute, hour, etc.? I totally understand that refreshing a dynamic list every second means a fresh communication with the server so you wouldn’t necessarily want it that often but in real terms, is it a big deal? I know the size of database will be key but let’s assume it’s 500 records, MySQL, fast server and not many visitors, should I avoid refreshing every second or even every 5 seconds?

I’ve created an admin area for members where lots of data is shown in a dashboard. People may leave themselves logged in and switch back to it from time to time so I want them to see the latest data but refreshing it every second just feels like it’s a bit too much.

Thoughts?