fixed import form wordpress plugin
[homepage.git] / src / _posts / 2016-02-10-light-in-realraum-is-now-faster.md
1 ---
2 id: 474
3 title: Light in realraum is now faster
4 date: 2016-02-10T06:28:54+00:00
5 author: xro
6 layout: post
7 guid: http://wp.realraum.at/?p=474
8 permalink: /2016/02/light-in-realraum-is-now-faster/
9 responsive_meta_box_designation:
10   - 
11 responsive_meta_box_facebook:
12   - 
13 responsive_meta_box_twitter:
14   - 
15 responsive_meta_box_googleplus:
16   - 
17 responsive_meta_box_text_linkedin:
18   - 
19 snap_MYURL:
20   - 
21 snapEdIT:
22   - 1
23 snapTW:
24   - 's:202:"a:1:{i:0;a:8:{s:2:"do";s:1:"1";s:9:"msgFormat";s:15:"%TITLE% - %URL%";s:8:"attchImg";s:1:"1";s:9:"isAutoImg";s:1:"A";s:8:"imgToUse";s:0:"";s:9:"isAutoURL";s:1:"A";s:8:"urlToUse";s:0:"";s:4:"doTW";i:0;}}";'
25 categories:
26   - english
27   - Projekte
28 ---
29 [licht.realraum.at](http://licht.realraum.at "licht.realraum.at"), went FTLw today. That is… it became much Faster Than Last week. :-)
30
31 Since the Raspbian image upgrade and move to a bigger (but slower) SDcard, licht.realraum.at had become truly sluggish. To the point that pressing a button to turn on the light or change the stereo volume could take up to 6 seconds until something happened. (Obviously we disabled the swap-file long ago.)
32
33 The problem was quickly identified. Processes don’t load quickly enough.
34   
35 The fact that the whole systems was a dunghill of bashscript cgi-scripts and python helper scripts also did not help. At all.
36
37 **First attempt** to rectify this: rewrite the python helper rf433ctl.py. Formerly it was a simple script that would be called by the cgi-script and send the appropriate bytes down to the teensy.
38   
39 Each call to it, however now took forever. So. I rewrote it as a daemon that would constantly stay in memory and be nudged by other instances of it via RPC. The idea being, if it’s already completely in memory, loading a second instance should be faster. Right? Wrong!. Unfortunately that did not work out at all.
40
41 **Second attempt** to rectify this: Remove the kiosk functionality and thus memory-hog midori from licht. Thankfully a very nice person gifted us a RaspberryPi per (almost) anonymous letter, so we had the necessary hardware on-hand to split the functionality onto two separate boxes: [`licht.realraum.at`](http://licht.realraum.at "licht.realraum.at") and `smallkiosk.realraum.at`
42   
43 Unfortunately, even freeing up 60% of memory did not even put a dent into the problem.
44
45 So.. **third and last attempt**. Hit it with go ;-> In a 3 hour session, I rewrote the whole dunghill as a [monolithic golang daemon/webserver/tty-handler](https://github.com/realraum/deckenlichtschalter/tree/master/linux/golightctrl) which, once loaded, always stays in memory. Then I got rid of lighthttpd and the python scripts. Result&#8230; Speedup from 6s to <=0.05s !! Should have done this right away really&#8230;