SteemWorld ~ Newsletter #3 / February, 2018

in #steem6 years ago (edited)

Parsing and compressing the blockchain for the SteemWorld Web API...

After I've successfully downloaded all blocks and saved the transactions in a local relational database, now the fun part begins.

How it works

My goal is to have one self-refreshing (current) db on my server that will only contain the data of the past few days/weeks so that the indices won't get to large and therefore write operations will always be executed with maximum performance. When a client makes a request to receive the new mentions, followers, etc. for an account the server will search in the (current) db and return the rows instantly.

After thinking about it for some hours, I came to the conclusion that my server needs to create new databases automatically in a defined interval and move the old db to a backup directory periodically. As I'm working with SQLite this can be done in a much easier and faster way than by using MySQL. The script for parsing new blocks and handling/creating the backup dbs will be executed by a Cronjob on the server. The filename for each db in the backup path will contain information about the date range of the in there stored data so that the server does not need to walk through millions of rows to retrieve data for a specific day. That makes it possible to retrieve old account operations very fast as well.

I've much experience in professional database administration/development and have worked with different big vendors like Oracle, Informix, Sybase (ASA) and MySQL for many years. Nevertheless I decided to use a purely file-based type of database and SQLite seems to be the perfect choice for me here (MongoDB would also work and may be my second choice). That also enables me to attach external db files easily (for example from backup dir) to an existing connection of the main (current) db and join the data within one SELECT-Statement (or multiple UNION's as well).

Better Compression

Since I want to save as much disc space as possible, I've written an own compression algorithm for the operations. Some of you might know that the transactions consist of much redundant data that could be saved in a much better way than just putting the complete JSON into a column. As far as I know, @dan has done similiar optimizations for EOS recently. Before the data will get deflated, the property names in the JSON Object will be replaced by 'Property IDs' which are automatically being stored in kind of a 'JSON IDs table'.

In theory it's done

One thing I've learned on my journey as developer is the importance of spending time in planning and thinking about different scenarios that can occur in a production environment. I know that there will be coming a huge number of requests from SteemWorld and I want to be well prepared for that. In most cases making big changes to a running system later lead to more headaches and sometimes unforeseeable consequences.

If you don't see any changes coming to the SteemWorld currently it is because the main work happens in background on many pieces of paper ;) Since I'm currently receiving new ideas for the site nearly every day, I'm thinking about creating an extra post for ideas/feedback/bug tracking and adding a link to it on SteemWorld, so that others can see what is already planned.

Please be patient and keep in mind that this is all being developed by me alone. I know that there are still many nice features missing in the tool and I will continue to work on them as soon as the Web API is running stable. As mentioned before, my current step will enable me to realize many cool things like desktop notifications for mentions/followers, a fast overview for incoming delegations and SP ranks as it has been on steemwhales.com.

[DE]

Parsen und Komprimieren der Blockchain für die SteemWorld Web API...

Nachdem ich alle Blöcke erfolgreich heruntergeladen und die Transaktionen in einer lokalen relationalen Datenbank gespeichert habe, beginnt jetzt der spaßige Teil meiner Arbeit.

Wie es funktioniert

Mein Ziel ist es, eine selbstaktualisierende (aktuelle) Datenbank auf meinem Server zu haben, die immer nur die Daten der letzten paar Tage/Wochen enthält, so dass die Indizes nicht zu groß werden und Schreiboperationen daher immer mit maximaler Leistung ausgeführt werden. Wenn ein Client eine Anfrage stellt, um die neuen Erwähnungen, Follower usw. für einen Account zu erhalten, sucht der Server in dieser (aktuellen) Datenbank und gibt die Zeilen sofort zurück.

Nachdem ich einige Stunden darüber nachgedacht hatte, kam ich zu dem Schluss, dass mein Server in einem definierten Intervall automatisch neue Datenbanken erstellen und die alte Datenbank regelmäßig in ein Backup-Verzeichnis verschieben muss. Da ich mit SQLite arbeite, kann dies viel einfacher und schneller erfolgen als mit MySQL. Das Skript zum Parsen neuer Blöcke und zum Bearbeiten/Erstellen der Backup-DBs wird von einem Cronjob auf dem Server ausgeführt. Der Dateiname für jede Datenbank im Sicherungspfad enthält Informationen über den Datumsbereich der darin gespeicherten Daten, sodass der Server nicht durch Millionen von Zeilen wandern muss, um Daten für einen bestimmten Tag abzurufen. Dadurch kann ich auch ältere Kontovorgänge sehr schnell anzeigen.

Ich habe viel Erfahrung in der professionellen Datenbankadministration/-entwicklung und habe viele Jahre mit verschiedenen großen Anbietern wie Oracle, Informix, Sybase (ASA) und MySQL gearbeitet. Nichtsdestotrotz habe ich mich für eine rein dateibasierte Art von Datenbank entschieden und SQLite scheint hier die perfekte Wahl für mich zu sein (MongoDB würde auch funktionieren und wäre wahrscheinlich meine zweite Wahl). Dies ermöglicht es mir unter anderem, externe DB-Dateien (z.B. aus dem Sicherungsverzeichnis) einfach an eine bestehende Verbindung zur Haupt- (aktuellen) DB anzuhängen und die Daten innerhalb einer SELECT-Anweisung (oder auch mehrerer UNIONs) zu verbinden.

Bessere Komprimierung

Da ich so viel Speicherplatz wie möglich sparen möchte, habe ich einen eigenen Komprimierungsalgorithmus für die Operationen geschrieben. Einige von euch wissen vielleicht, dass die Transaktionen aus vielen redundanten Daten bestehen, die viel besser gespeichert werden können, als einfach nur den kompletten JSON-String in eine Spalte zu schreiben. Soweit ich weiß, hat @dan kürzlich ähnliche Optimierungen für EOS vorgenommen. Bevor die Daten deflationiert werden, werden die Eigenschaftsnamen im JSON-Objekt durch 'Eigenschafts-IDs' ersetzt, die automatisch in Form einer 'JSON-IDs-Tabelle' gespeichert werden.

In der Theorie ist es getan

Eine Sache, die ich auf meiner Reise als Entwickler gelernt habe, ist die Wichtigkeit, Zeit in die Planung und das Nachdenken über verschiedene Szenarien zu investieren, die in einer Produktionsumgebung auftreten können. Ich weiß, dass SteemWorld eine große Anzahl von Anfragen erhalten wird und darauf möchte ich gut vorbereitet sein. In den meisten Fällen führen später gemachte, große Änderungen in einem laufenden System zu mehr Kopfschmerzen und manchmal unvorhersehbaren Folgen.

Wenn man also momentan keine Änderungen in der SteemWorld sieht, liegt das daran, dass die Hauptarbeit im Hintergrund auf vielen Zetteln Papier stattfindet ;) Da ich momentan fast täglich neue Ideen für die Seite erhalte, denke ich darüber nach, einen zusätzlichen Post für Ideen/Feedback/Bug-Tracking zu erstellen und einen Link dort hin auf SteemWorld.org zu platzieren, damit andere sich austauschen und sehen können, was bereits geplant ist.

Bitte habt etwas Geduld und bedenkt, dass dies alles nur von mir alleine entwickelt wird. Ich weiß, dass im Tool noch viele schöne Funktionen fehlen und ich werde weiter daran arbeiten, sobald die Web-API stabil läuft. Wie bereits erwähnt, wird mein aktueller Schritt es mir ermöglichen, viele coole Dinge wie Desktop-Benachrichtigungen für Erwähnungen / Follower, eine performante Übersicht für eingehende Delegationen und SP-Ränge zu realisieren, wie es auf steemwhales.com früher mal der Fall war.

In the meantime...

New buttons for showing the incoming/outgoing votes:


Links

SteemWorld.org/@YourAccountName


The Web API will make many awesome things possible on SteemWorld. As soon as I reach the point where I'm able to pay my bills with my work for the community, I will make it publicly accessible on a fast @privex server so that every developer can use it to easily retrieve data from the blockchain and to build/improve their own Steem tools.

Thank you all for the great support!


Sort:  

Definitely the best Steem tool so far. You see and get everything. All relevant data is in front of your eyes with a bit of scrolling and mostly one click away.

Awesome! Truly awesome.

Question - will we be able to tap into your database?

Question 2 - how will you implement search and filter functions. These are sadly inadequate now with current Steem APIs...

Thank you very much!

will we be able to tap into your database?

Yes, I've planned to make the Web API public as soon as I can make a living with my rewards here. I would probably get me two fast privex machines. One for steemworld itself and one for other developers.

how will you implement search and filter functions. These are sadly inadequate now with current Steem APIs...

That is one reason why I'm building the API. I think the public steem nodes should not be used for most developer tools because there are just a hand full nodes available and nearly every week there come new tools which all are making many requests to these few. That won't work well much longer I think.

For the search and filter functions I will create an extra db because I need huge full text indices for a much larger time period and that of course can't be done by joining all the weekly databases.

The API will have some parameters for searching and filtering so that one can retrieve only the operations of a specific kind, posts with desired tags/text etc.

Glad that you will eventually be opening up to other devs! I'm an analyst and DB guy myself, so I love me some data! When you do open up the API, I'd like to work on making more of a visualization dashboard for those who are less data-savvy!

I have a suggestion but first thanks for creating what I consider to be the best statistic site for the platform. I would recommend it to anyone.
The suggestion is based around a column that you already have so more of an update really, On the feed section you have created a followers sub section which includes; Followers not following & following not followers. Brilliant by the way. It's easy for me to use as a new user because I don't have much data to surf to find out what I need to know however this is getting harder as my account grows just through the sheer volume of traffic.
If a user has thousands of follows as apposed to my hundreds it will become harder to monitor the progress in this field as I don't wish to follow everybody just because they follow me especially if they have opened an account with good intention but are never going to actually use it.
So my suggestion is to add 2 fields to this section to make it easier for users with thousands of followers to spot new activity on their accounts.
The first section I would call New Followers; Add to this section any users who have become new followers in the last week; The benefit is that when I look here I will see new followers without having to sift through users that I have already decided not to follow that are currently appearing on followers not following.
The second section I would call inactive followers; add to this users who haven't posted, commented or voted on anything at all in the last fortnight; The benefit is that I don't have to keep following a user that mutually will probably never engage in any activity with. i.e they have no post for me to comment or vote on & they will never engage in my own blog which makes following them a complete waste of time.
It's your work so feel free to tweak, change or scrutinize.
Kind regards & keep up the good work.

Thanks for your great ideas! Your points are now on my todo list and I will think about ways for implementing it when the Web API is running stable ;) I've planned to save kind of an activity status for each account on my server and I think that I can use it for realizing your second point.

Thanks I'm pleased you liked the ideas & look forward to seeing them implemented. I have Steemworld open in a 2nd tab whenever I'm on Steemit it makes the platform a breeze to use. I recommend it to every new user I connect with.

Ein bereits jetzt geniales Tool. Wer kein Programmiere ist oder zumindest etws ähnliches macht wie du, kann sich nur sehr schwer vorstellen was da für Arbeit dahinter steckt.

Ich bin selbt jahrelang neben einem Programmierer gesessen. (Nein ich kann das nicht! ;) )
Wenn es so scheint als würde nichts passieren und man auch keine Ergebnisse sieht, dann befindet sich der Programmierer genau bei seiner Arbeit! Das ausdenken, duchdenken ist das schwierigste dabei. Wenn die Idee oder Lösung da ist, geht es ans Programmieren. Auch viel Arbeit! Aber das Lösung finden ist denke ich die größte Herausforderung dabei. ;)

Ich habe meinen Programmier-Kollegen wirklich sehr gerne neben mir gehabt! Nicht weil er still war! Nein, er hatte seinen eigenen Charme und Witz. Konnte mir technische Sachen erklären wie kein Anderer. Wahnsinn (positiv gemeint!) wie ein Programmierer an Dinge herangeht um sie zu lösen. Respekt vor der Arbeit und danke für deinen Einsatz! :)

That sounds like an immense job and it goes to further prove what I already know about Steemit - there are some really clever people here.

Thank you for your work.

Mind = blown.

Thank you again for all of the hard work! Steemworld is by far the best site for STEEM stats that I've seen, and I highly recommend it to others who have not tried it out yet!

Einmal mehr herzlichen Dank für das beste aller Steemit-Tools! Ich habe es immer in 4 Tabs gleichzeitig offen und schaue täglich als erstes in meine SteemWorld, noch bevor ich auf Steemit gehe. Es ist interessant, dass du uns an deiner Hintergrundarbeit mit viel vorausschauend, weit, breit und tief denken und planen teilhaben lässt. Da bekommt man eine ungefähre Vorstellung von dem enormen Aufwand. Wie so oft ist die meiste Arbeit die, die man nicht sieht.

Fantastic work! It reads very difficult to do!

Thanks! Yes, the huge amount of transactions is the main reason for the need of a very well thought solution. But I'm happy that I've found a good way. Even if it is still theoretical and my ideas are just written on paper, I know that it will work ;)

You are awesome! I truely admire you and all people who are able to code those complicated programs.

          I would like to throw my thanks in with all the others. I use it everyday, I am very appreciative of the manual vote slider. It takes a bit, but I use it almost all the time now on votes, even on some votes that are full power votes. That tool is a god-send for us less than minnows.
          Really looking forward to the mentions tool when it comes out. I love the vote indicator, my 'oh $hit I voted to much' warning graph.
          The incoming and outgoing vote tool is great also. I have found that I sort of rely on it to let me know that "oops" forgot to go give them any votes lately meter. For some reason though the incoming votes graph has not wanted to work in the last few days, I don't use it as much, but I do like to know who is voting my content, so I can make sure I visit their blogs to give votes if needed.
          I think, as I have told a lot of people, steemworld is a great tool.

I've been using your SteemWorld "tool" and have to say I love it!! It's amazing and continually open on my laptop. I feel badly that I never thought to check out your newsletter, and now I find you're doing this all by yourself!! Thank you, thank you, thank you!! Cheers!

@steemchiller, vielen Dank für deine tolle Arbeit bis jetzt. Das was die Developer-Tools in den Browsern für die Webentwickler sind, ist Steemworld für die Power-User auf Steemit.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 63960.62
ETH 3142.95
USDT 1.00
SBD 3.95