Skip to main content

Ralsina.Me — Roberto Alsina's website

(Re)Introducing Alva, a Nikola Server

Over a year ago (time flies!) I post­ed some­thing about a project called Al­va. Let me quote my­self:

Al­va is al­most the op­po­site of Niko­la. If Niko­la is about mak­ing stat­ic sites, Al­va is a dy­nam­ic site. How­ev­er, as Hegel sug­gest­s, from the the­sis and the an­tithe­sis comes the syn­the­sis.

So, Al­va is about dy­nam­i­cal­ly cre­at­ing stat­ic sites. If you want to have Niko­la in your serv­er in­stead of in your own com­put­er, and have the con­ve­nience of an on­line tool, that's the niche Al­va tries to fil­l.

So, you would in­stall Al­va, and use it like any oth­er we­b-based blog­ging tool. Yet, be­hind the sce­nes, you would have Niko­la, and all the per­for­mance and se­cu­ri­ty ben­e­fits of stat­ic sites.

And maybe some­day, I (or some­one) will put up a mul­ti­-us­er ver­sion of Al­va, and you will be able to get host­ed blogs, know­ing all the da­ta is yours and you can leave any­time and do your own thing.

The ap­proach I was tak­ing at the time proved to be un­suc­cess­ful, and there were a few oth­er fail­ures along the way. Of course, the prob­lem was in how I was ap­proach­ing the task. So I did the right thing, and learned how to do it "right".

Still not us­able, still not host­ed any­where, but al­ready semi-­func­tion­al: Al­va lives now

There's a lot of work still to be done. But I now know how to do it. To pre­vent the usu­al ar­gu­ments, here is a lit­tle ex­pla­na­tion of mo­ti­va­tion, tool­ing, etc.


I want a way to host blogs very cheap­ly. How cheap­ly? I want at least 1000 rea­son­ably ac­tive users in a $5 VP­S. That would make Al­va a rea­son­able al­ter­na­tive to host­ed mul­ti­-us­er word­press, which means it would be a rea­son­able so­lu­tion (if set­up is easy enough) for smal­l­-­to-medi­um or­ga­ni­za­tions which don't want to set­up ex­pen­sive in­fra­struc­ture yet want to own their da­ta (think school­s, small busi­ness­es, FLOSS pro­ject­s, etc.) I al­so want to pro­vide that ser­vice, for free. Which is why an­oth­er rea­son I want it to be su­per cheap.

How does Al­va help pro­vide this su­per-cheap blog host­ing?

  1. It needs to scale fol­low­ing the num­ber of ed­its not views.

  2. If it gets too busy with ed­it­s, changes take longer to ap­­pear, but the site it­­self does­n't get any slow­er.

  3. Ed­it­ing and serv­ing can be pro­vid­ed by sep­a­rate ser­vices, so I can use some su­per-­­fast stat­ic file serv­er and a su­per-­­con­­fig­urable WS­­GI de­­ploy­­men­t.

  4. In­­di­vid­u­al pages can be heav­i­­ly op­ti­mized so that they down­load fast


One of the guid­ing prin­ci­ples here is that to de­liv­er this sort of thing, in my spare time, the de­vel­op­ment process needs to be stingy with the most lim­it­ed re­source: me. I can't spend a lot of me here. I need to be care­ful and not over-promise.

So, when­ev­er there was a 3rd-­par­ty tool that saves a sig­nif­i­cant amount of time, that's what I am us­ing.


Be­cause it has a much stronger 3rd-­par­ty toolset than Flask or any mi­cro-frame­work. For ex­am­ple, the Flask equiv­a­lent of djan­go-al­lauth broke my will to live. Be­cause the ad­min in­ter­face means I can start adding da­ta to see if it makes sense be­fore I write all the re­quired views.


Be­cause I don't want you to have to cre­ate ac­counts here un­less you want to, this pro­vides (op­tion­al) so­cial lo­gin and reg­is­tra­tion. This was easy to set­up and works alm­sost out­-of-the-box

Bootstrap and Django-bootstrap-toolkit

Niko­la is al­ready heav­i­ly in­vest­ed in boot­strap, so it just made sense to go fur­ther down that road. I un­der­stand boot­strap, and djan­go-­boos­t­rap-­toolk­it is easy enough (although I can't make their datepick­er work)


Be­cause fight­ing is bor­ing.


Be­cause Djan­go's mech­a­nisms to find tem­plates and stat­ic files are many and con­fuse me.

Redis + RQ + django-rq

It's crucial for the whole approach to use job queues in order to detach the rendering from the actual Django app. This combination makes job dispatching ridiculously easy, setup is trivial (install everything, start redis, a few lines of config, ./ rqworker and off you go) and they provide a django admin page where I can see the failed jobs, which is awesome.


Be­cause it's easy enough, and al­lows me some free­dom ex­plor­ing da­ta or­ga­ni­za­tion in my mod­els with­out com­mit­ting to it for­ev­er or recre­at­ing data­bases with test da­ta all the time.


I will prob­a­bly serve the gen­er­at­ed sites via gatling just like my cur­rent sites be­cause it has the sim­plest named do­main con­fig­u­ra­tion pos­si­ble, it's fast and very light in re­source us­age.


A cool, sim­ple ed­i­tor with live pre­views that sup­ports al­most ev­ery markup. Not WYSI­WYG or even WYSI­WYM so pos­si­bly I will have to add an al­ter­na­tive. I start­ed us­ing djan­go-­mark­it­up but it's not a good idea (it us­es a old ver­sion of mark­it­up which re­quires JQuery < 1.9) and am in the process of just us­ing Mark­it­up man­u­al­ly.

So, feel free to give Al­va a try and/or give me a hand, com­ments wel­come.

Contents © 2000-2024 Roberto Alsina