Erlang White Label

30
WhiteLabel Erlang Adventures in the undocumented wilds of inet_dns

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

Page 1: Erlang White Label

WhiteLabel ErlangAdventures in the undocumented wilds of inet_dns

Page 3: Erlang White Label
Page 4: Erlang White Label
Page 5: Erlang White Label

What have I been up to?ejabberd

debuggingvirtual hostingdebugging large clustersporting patchesdebugging patches

Page 6: Erlang White Label

What have I been up to?Whitelabel ejabberd hosting

Page 7: Erlang White Label

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

A rant in four parts

Page 8: Erlang White Label

ErlywebYAWSinetsThe Erlang WebNitrogen

Web Frameworks

Page 9: Erlang White Label

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

Page 10: Erlang White Label

Other piecesTemplatingURL RoutingForm validationEmail

Page 11: Erlang White Label

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

Page 12: Erlang White Label

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

Page 13: Erlang White Label
Page 14: Erlang White Label

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

Page 15: Erlang White Label
Page 16: Erlang White Label

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

Page 17: Erlang White Label

Mail Sending API

Page 18: Erlang White Label

Mime Attachment API

Page 19: Erlang White Label

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

Page 20: Erlang White Label
Page 21: Erlang White Label

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

Page 22: Erlang White Label

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

Page 23: Erlang White Label

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

Page 24: Erlang White Label

Whitelabel TricksCheck SOA to test if domain existsBypass DNS caching

Page 25: Erlang White Label

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

Page 26: Erlang White Label

Minifying...

Page 27: Erlang White Label

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

Page 28: Erlang White Label

Use Github.

Page 29: Erlang White Label

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

Page 30: Erlang White Label

Fin.