July News
tags: brussels dev party python search union-of-rock wikidot
1248795663|%e %B %Y
Some of you may be more used to me posting more often, than in last time.
Some of you may wonder why I stopped blogging.
Brussels
Last month was full of adventures. It started 1st of July with me going to Brussels meat our friend to talk about wikipedia-like site about art. We're going to help this man build the most complete site about art using Wikidot software!
BTW, this was my first flight in lifetime. Quite a strange feeling, but generally fine.
Forms
I was working on some nice technical and UI improvements to Wikidot, that is crucial for the art site (but really really nice for Wikidot as well, like forms for editing, entering and viewing structured data to wiki pages).
Search issues
That week was also spent on some massive Wikidot.com search engine tweaks. A stupid one-line bug, which was not exporting proper LC_ALL environmental variable in indexing script, caused many sites that used Asian or East-European languages to be not indexed (most notably the great ИСТОРИЈСКА БИБЛИОТЕКА). At first we though that we can re-index the broken sites, but our re-indexing mechanism was way too slow (would last for weeks for all broken sites).
Pieter then challenged me. He said he can index whole Wikidot in 6 hours. I thought it's not even possible, but then I started to work on that and I managed to index the whole Wikidot in less than 2 hours without indexing tags at first. Then with tags, it took 2 hours and 10 minutes or so. That was damn fast!
Inspired by this and an accident of disk full error on /var partition of our webserver (but this is why we keep user-uploaded files and other important things on separate disks), I also rewrote the incremental indexer, to work in similar way to the whole-Wikidot-re-indexer.
search-api reindex
If you care about some technical details:
- all search operations are issued with use of search-api, a separate program that can:
- re-index whole Wikidot
- queue indexing page/thread
- queue deleting page/thread
- queue re-indexing site
- flush queue
- search-api is written in Python
- search-api uses PyLucene - a native Java Lucene library binded to CPython objects with PyJCC. Compiled with GNU Java Compiler to native code (like C programs), this binding has improved performance over using Lucene with Sun's Java.
- before rewriting it to only-Python, search-api was written in BASH and was a wrapper to:
- java -jar searchApiHelper.jar search "phrase-to-search"
- php search-api-helper.php flush
- search-api also takes care of file locking to assure that
- only one process tries to modify the index
- items are added to queue one-after-another
- when doing some big index modification (read: full re-index) queue is not flushed (so that after the re-index all changes are applied to new index)
- when flushing queue takes more time, and cron tries to run more flushing processes, they simply end (so only one process flushes the queue at a time)
Union of Rock Festival
Just after week spent in Brussels in nice hotel I went to Węgorzewo, Mazury (Poland biggest lakes distinct) to have fun on rock music festival. Unfortunately, the music level was not very impressive, so I mainly enjoyed the atmosphere on the camping area.
The weather was not great. It was wet everywhere, the ground was covered in 20 centimeters of mud and it was hard to walk around without getting dirty. But during the first day of being there, I learned to do that.
Improved workflow at Wikidot
Some of you noticed, that recently we started to work more efficiently, but this is not quite true. In fact we work as efficiently as before, but we are better organized, and have better priorities on tasks. Also we keep track of what we do, so we can then tell what we've done. So for us, this is a little more work of "documenting" our work (so maybe we work even less efficiently than before?), but for the outside world, we make more noise (in a positive meaning) around that. So basically, people know what we do, what we are going to do, when they can expect changes and most importantly, they understand why some feature request is being postponed. This is (and was) because we have more important things to do, but before they couldn't tell it.
Squark turned into a professional project manager, that manages our time.
pieterh decided to talk to the Community and listen to their complaints (he reads or at least skims every post on Community forums). He tells Łukasz what needs to be done, Łukasz knows when we will have time to do this. This way communication inside Wikidot improved. Also we (
michal frackowiak and me) no longer look on Community forums (some of you may regret), but this allows us to concentrate on our work.
The work continues
As I mentioned before, we want to introduce a great feature to Wikidot, which is forms. But the implementation now concentrates on the open source version of Wikidot software (once it's ready, working and tested we'll copy the feature to the Wikidot.com service).
aptitude install wikidot
As forms is a huge change, I started to prepare a good ground for it and closed most important bugs in Wikidot open source and I'm about to start making Ubuntu packages for it to allow even-simpler installation on Debian-based systems. Now the installation involves only 6 child-easy steps and in fact can be done by copying&pasting a few commands.
Yesterday's party
Yesterday I went to met some old-school-times friends in the heart of the city. It was meant to be a meeting for "a beer or two" but evolved into beer and dancing till morning. That was first time I get a morning bus (not even the first) to my home just after partying.
It was such a great fun and great folks I met.
Summary
I hope with this long blog post (but divided into friendly sections ;) ) I recompensed long period of not-posting anything here.
Comments: 0, Rating: 1
Lucene Replaces Local Searches
tags: dev lucene search wikidot
1245781558|%e %B %Y
As some of you know, some time ago I worked on a new Wikidot search. It is used for the Search all sites page.
This work was done, because searching the whole Wikidot database was far from being fast. At first we used Google Custom Search Engine to solve the problem, but we wanted to be independent from it. Also we wanted to include search results that are accessible by the person that searches but not by search engines (like private sites).
This worked really good. The only problem was long time spent to display the results. It was like 20 seconds, which was far better than when using previous search, but much worse than Google. This was strange, because from previous tests, we calculated the average search time should be about a second or two.
It started to be clear, when we noticed that only 20-30 searches per day are performed. The index is quite big, and it needs to be cached in RAM to work with sufficient performance.
Today I did more tests under heavy load and it seams Lucene can handle big number of queries. When users search often, the index is partially or even fully cached by the filesystem and searches are really quick!
But our main problem to solve today was slow local search a.k.a. "search this site". Moreover many concurrent queries were degrading database performance (not only for searching), so we decided to enable Lucene for local searches as well.
I must say it works really nice, fast and has a nice set of syntax tricks you can do with it, for example you can search for pages with something in tags. Just search for youtube tags:embed. This would search for pages matching youtube (in tags, title or content) and with embed in tags. If no such pages are found, partial matches are also returned, like: pages matching youtube (but with no embed in tags) or pages with embed in tags, (but not matching youtube).
To sum up, new search is faster, gives more accurate results, saves the database performance (which was the main goal) and allows nicer syntax than the old one.
Comments: 7, Rating: 1
PHP as FastCGI backend and Lighttpd
tags: dev fastcgi lighttpd php problem solved wikidot
1245099569|%e %B %Y
Wikidot + Lighttpd + PHP5
At Wikidot we use PHP5 as FastCGI backend to Lighttpd light-and-fast webserver. It works like this:
- there are a few hundreds of php5-cgi processes (name is cgi, but they also support FastCGI mode) running and waiting to be used
- lighttpd (only one needed!) process manages the network connections to all the clients and once the request is ready serves a static file or forwards the request to one of PHP backends processes.
We used to use internal Lighttpd FastCGI process manager, meaning the lighttpd processes actually used to start the PHPs.
Problems
We encountered some known problems of 500 (server side) errors appearing after some random time, especially under a high traffic. The typical message appearing at the Lighttpd's error.log was:
<some date>: (mod_fastcgi.c.2494) unexpected end-of-file (perhaps the fastcgi process died): pid: ...
There are plenty of reports on this in both Lighttpd's and PHP's forums, bug trackers and even some blogs.
Workarounds
We managed to write some hacky scripts that detected the situation and restarted the backends when needed. The reaction was so quick, that almost no-one noticed the error, but damn, this is not how WE solve problems.
A blind try
We decided to give spawn-fcgi a shot. What is it? It is a program that spawns FastCGI backends (independently from Lighttpd server). Why trying it? I've read somewhere, that it works more reliably than the internal Lighttpd spawner. What's interesting is that this program comes from lighttpd package, so we're in family anyway. It's mainly intended to run the FastCGI backends from different user than the webserver user or to run them on different machine(s) than the webserver machine. This can be used naturally for some smart load-balancing.
The only problem of this solution we encountered was internal limit of number of processes to spawn by a single process which was 256 (hardcoded, fixed in next versions). But at the same time, we decided to build a few FastCGI bridges (each spawning ~200 PHPs) anyway so that was no longer a problem for us.
What was quite surprising (but honestly, I deeply believed in this), our problems with 500 server errors and PHP disappeared. This configuration works for about 2 weeks now with absolutely no hacky scripts involved and no restarting needed. Cool.
Why I wrote this
I wrote this short note just for the record and to let other people know, that using spawn-fcgi instead of the internal Lighttpd's FastCGI spawner might solve their problems with PHP (FastCGI) and 500 internal server errors.
Hope this helps someone.
Comments: 1, Rating: 0
Refreshing www.wikidot.org
tags: blog dev opensource wikidot
1242929477|%e %B %Y
Yesterday I started refreshing www.wikidot.org website — the home of Wikidot open source software.
Also we decided to move from managing our code in SVN to Git — more precisely to www.github.com. Our project page at GitHub is the following: http://github.com/gabrys/wikidot. Feel free to just follow it or even fork!
Last times, I made Wikidot insanely easy to install (check out the installation guide). It totally rocks (you can install Wikidot within 10 commands and no file editing).
I want to state, that this post is the last about the Wikidot open source software on this blog, as I'm running a new blog just about the Wikidot software at wikidot.org. This will be more practical to filter the posts and will push some life into that site.
At the end I want to invite you to the Wikidot IRC channel #wikidot at irc.freenode.org. That would be probably the easiest way to contact the Wikidot team without much formalism.
(As many posts here were about Wikidot software, this blog will be less regularly updated, but if really care about Wikidot software news, just follow the new one and you won't be spammed about posts about Python, BASH or other things. I hope that blog-split will really help everyone.)


