Erlang White Label

Post on 24-Jan-2015

1.648 views 3 download

description

Geoff Cant Whitelabel Erlang covers the trials, tribulations and technologies used in building a whitelabel ejabberd hosting service.The talk explains the rationale behind the choices of web server, templating system, email module, page optimizers and other web framework components. The talk also covers the documented and undocumented DNS query and caching modules in OTP and introduces 'dns' - a convenient new API for using them. Finally, the talk describes some tips and tricks useful for whitelabel hosting solutions that require customer DNS updates.

Transcript of Erlang White Label

WhiteLabel ErlangAdventures in the undocumented wilds of inet_dns

Who is this guy?Geoff Cant <nem@erlang.geek.nz>Current (xmpp|mailto):gcant@process-one.netPreviously geoff@catalyst.net.nzarchaelus on http://github, irc:freenode/#erlang

What have I been up to?ejabberd

debuggingvirtual hostingdebugging large clustersporting patchesdebugging patches

What have I been up to?Whitelabel ejabberd hosting

Web Frameworks (why Mochiweb)Other libraries (ejango, esmtp, erlydtl)DNS (OTP Undocumented)Tricks and Lessons

A rant in four parts

ErlywebYAWSinetsThe Erlang WebNitrogen

Web Frameworks

Mochiweb.(No logo, ‘cause they’re too busy coding)

Other piecesTemplatingURL RoutingForm validationEmail

TemplatingerlydtlTemplates compile to modulesWell known template syntax (Django-ish)Template

URL RoutingMust work with RESTful URLsMust be reversible - able to generate URLs tooejango.url_routes

Form ValidationGenerate forms and validate form postsCouldn’t find anything available alreadyDeclarative DSL for form specificationejango.form, ejango.form_validator

Sending Emailsmtp_fsmErlware smtpNo attachments?This should be much easier.esmtp

Mail Sending API

Mime Attachment API

DNSNeed to verify ownership of domainNeed to add XMPP SRV recordsinet:gethostbyname...To the githubs!

DNS Undocumentedinet_res:getbyname/2inet_res:nnslookup/5inet_db - cachinginet_dns - packet encoding/decoding, bugs‘dns’ -- the way forward.

Here be Dragons.Sometimes it’s undocumented for a reasonThe TXT RR is subtle.I reimplemented the same bug.

My DNS decoderTXT RRs are <<Len:8, Data:Len/binary>>* Binary pattern matching rocks

Whitelabel TricksCheck SOA to test if domain existsBypass DNS caching

YSlow OptimisationsInitially got a D on my YSlow reportDecided to gzip and minify content, move js blocks aroundejango.static:compress_docroot/1, ejango.static:serve_compressed/3

Minifying...

LessonsHierarchal modules are a world of hurt.Metaprogramming in Erlang is still too hard.Never trust ADSL routers....

Use Github.

A small plea for helpI have way too many github projectsAdopt my code?Interested in collaborating?

Fin.