SlideShare a Scribd company logo
1 of 29
Download to read offline
Using LuaJIT in mid-load web-projects
Alexander Gladysh
CTO, LogicEditor
On Lua and LuaJIT
Lua:
• powerful,
• fast,
• lightweight,
• extensible,
• embeddable
scrip ng programming language.
Language
On Lua and LuaJIT
• Origins.
• Popularity growth.
• Where is Lua used?
• LuaRocks.
Popular Dialects
On Lua and LuaJIT
• Lua 5.1 vs. Lua 5.2,
• LuaJIT 2.0,
• Metalua.
LuaJIT 2.0
On Lua and LuaJIT
• JIT, FFI, performance.
• Limita ons on x86 64.
• LuaJIT vs. Lua 5.2.
Why Lua?
On Lua and LuaJIT
Historically: We're coming from computer games industry, where Lua "rules the
world".
Pragma cally:
• Works fast!
• Pleasant to code!
• Easy to learn!
Where to get programmers?
On Lua and LuaJIT
Reeduca on.
Main problems learning Lua
On Lua and LuaJIT
• Mindless nkering with the language.
• NIH-syndrome. Lua is to easy to nker with.
• Diverging from the mainstream. Costs and benefits.
• Language idiosyncrasies:
• Global variables by default.
• Arrays are indexed from 1.
• Size of array with nil element is not defined.
• Everything that is not nil or false — true (0 too).
Most important!
On Lua and LuaJIT
When you code in Lua —	code in Lua!
Lua / LuaJIT place in your stack
On Lua and LuaJIT
First and foremost:
• User-configurable business-logic.
• Code that would otherwise be wri en in C/C++/OCaml.
Frameworks to build webservices with Lua
Our stack
Some of the popular ones:
• Kepler/WSAPI
• OpenResty
• Luvit
We have a "bicycle", built on WSAPI.
What web-problems are we solving with Lua?
Our stack
• Browser and social games.
• Ad networks.
• Other web-services, mobile games etc.
Hardware
Our stack
• Linode
• Hetzner EX6
OS
Our stack
• Xen XCP on top of Ubuntu Sever.
• domU on Ubuntu Server:
• HTTP frontends (nginx).
• HTTP backends (32-bit).
• Workers (32-bit).
• DB (Redis, MySQL).
• Aux (Bind, nginx-based config-server, deployment, monitoring etc.).
Backends
Our stack
• nginx
• spawn-fcgi + mul watch
• LuaJIT 2.0
• FCGI/WSAPI
• Applica on code
Workers
Our stack
• runit
• LuaJIT 2.0
• Applica on code
IPC
Our stack
• ØMQ
• Tasks:
• Replacement for broken signals.
• In-process cache reset.
• (Workers get tasks via Redis.)
System tuning
Our stack
• OS
• bit.ly/kernel-magic (for frontends and backends)
• Redis
• I/O Scheduler: noop on guests, deadline on host
• nginx
• worker rlimit nofile
"DevOps"
Our stack
• Deployment
• High Availability
• Monitoring
Main libraries
Our stack
• lua-nucleo, lua-aplicado (be er — Penlight, telescope)
• slnunicode
• luatexts, luajson
• luasocket, luaposix (be er — ljsyscall)
• WSAPI
• lua-zmq
• lua-hiredis (be er — ljffi-hiredis)
• luasql-mysql
DSL and code genera on
Our stack
• HTTP request handlers.
• Code (par ally sta cally validated).
• Docs.
• (Planned) Smoke-tests.
• SQL schema.
• "ORM" wrapper code.
• DB schema patches.
• Auto-backoffice.
• Docs.
• bit.ly/lua-dsl-talk
• Common parts of a project are generated from text templates.
Performance
Our stack
• About 160M synthe c hits per day per EX6-class server in ad networks.
• About 8K simultaneous ac ve users per EX6-class server in online games.
What did we encounter?
Pi alls
In main:
• Couple "mysterious" problems, due to bugs in early LuaJIT2 betas (all fixed by
now).
• Problems, caused by two versions of the same LuaRocks package installed in
the system.
• Exploding Redis.
• Lousy Hetzner HDD reliability.
Diagnos cs, debugging and monitoring
Pi alls
• Par al sta c code valida on.
• Run me valida on.
• Autotests.
• GC tuning and monitoring.
• Monitoring for request mes, memory usage etc.
• Debugging with logs.
Main unsolved problems
Pi alls
• Long polling / Comet.
• OS signal handling.
• More efficient CPU usage with HTTP handlers.
• LuaRocks:
• Can install two versions of the same rock in the system.
• Can't upgrade a package.
Next genera on stack
• Unblocking API with corou nes, no callback. Get inspired by, or adapt
OpenResty.
• Complete transi on to LuaJIT FFI.
• Consider dropping LuaRocks.
• Drop FCGI, move to epoll and lua-h p-parser.
• Simplify the architecture as much as possible. Drop the configura on server.
More code genera on!
• New DSL design.
Want to know more?
Official Site lua.org, luajit.org
Wiki lua-users.org/wiki, wiki.luajit.org
Mailing Lists lua.org/lua-l.html, luajit.org/list.html
StackOverflow stackoverflow.com/ques ons/tagged/Lua
IRC #lua at irc.freenode.net
Ques ons?
@agladysh
ag@logiceditor.com
meetup.com/Lua-in-Moscow

More Related Content

What's hot

May 2013 HUG: Building common denominator of Hadoop distributions with Bigtop
May 2013 HUG: Building common denominator of Hadoop distributions with BigtopMay 2013 HUG: Building common denominator of Hadoop distributions with Bigtop
May 2013 HUG: Building common denominator of Hadoop distributions with BigtopYahoo Developer Network
 
Php core. get rid of bugs and contribute
Php core. get rid of bugs and contributePhp core. get rid of bugs and contribute
Php core. get rid of bugs and contributePierre Joye
 
Streaming huge databases using logical decoding
Streaming huge databases using logical decodingStreaming huge databases using logical decoding
Streaming huge databases using logical decodingAlexander Shulgin
 
MyRocks in MariaDB: why and how
MyRocks in MariaDB: why and howMyRocks in MariaDB: why and how
MyRocks in MariaDB: why and howSergey Petrunya
 
MariaDB with SphinxSE
MariaDB with SphinxSEMariaDB with SphinxSE
MariaDB with SphinxSEColin Charles
 
Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkDvir Volk
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyAlexander Kukushkin
 
Ten Reasons Why You Should Prefer PostgreSQL to MySQL
Ten Reasons Why You Should Prefer PostgreSQL to MySQLTen Reasons Why You Should Prefer PostgreSQL to MySQL
Ten Reasons Why You Should Prefer PostgreSQL to MySQLanandology
 
HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)
HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)
HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)Ontico
 
Best practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityBest practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityColin Charles
 
GSoC2014 - Uniritter Presentation May, 2015
GSoC2014 - Uniritter Presentation May, 2015GSoC2014 - Uniritter Presentation May, 2015
GSoC2014 - Uniritter Presentation May, 2015Fabrízio Mello
 
Drupal MySQL Cluster
Drupal MySQL ClusterDrupal MySQL Cluster
Drupal MySQL ClusterKris Buytaert
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Colin Charles
 

What's hot (19)

May 2013 HUG: Building common denominator of Hadoop distributions with Bigtop
May 2013 HUG: Building common denominator of Hadoop distributions with BigtopMay 2013 HUG: Building common denominator of Hadoop distributions with Bigtop
May 2013 HUG: Building common denominator of Hadoop distributions with Bigtop
 
Tuning Linux for MongoDB
Tuning Linux for MongoDBTuning Linux for MongoDB
Tuning Linux for MongoDB
 
Devcon hh-2012
Devcon hh-2012Devcon hh-2012
Devcon hh-2012
 
Php core. get rid of bugs and contribute
Php core. get rid of bugs and contributePhp core. get rid of bugs and contribute
Php core. get rid of bugs and contribute
 
Streaming huge databases using logical decoding
Streaming huge databases using logical decodingStreaming huge databases using logical decoding
Streaming huge databases using logical decoding
 
MyRocks Deep Dive
MyRocks Deep DiveMyRocks Deep Dive
MyRocks Deep Dive
 
MyRocks in MariaDB: why and how
MyRocks in MariaDB: why and howMyRocks in MariaDB: why and how
MyRocks in MariaDB: why and how
 
RocksDB meetup
RocksDB meetupRocksDB meetup
RocksDB meetup
 
MariaDB with SphinxSE
MariaDB with SphinxSEMariaDB with SphinxSE
MariaDB with SphinxSE
 
Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and Spark
 
Say Hello to MyRocks
Say Hello to MyRocksSay Hello to MyRocks
Say Hello to MyRocks
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easy
 
Ten Reasons Why You Should Prefer PostgreSQL to MySQL
Ten Reasons Why You Should Prefer PostgreSQL to MySQLTen Reasons Why You Should Prefer PostgreSQL to MySQL
Ten Reasons Why You Should Prefer PostgreSQL to MySQL
 
Scalability
ScalabilityScalability
Scalability
 
HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)
HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)
HighLoad Solutions On MySQL / Xiaobin Lin (Alibaba)
 
Best practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High AvailabilityBest practices for MySQL/MariaDB Server/Percona Server High Availability
Best practices for MySQL/MariaDB Server/Percona Server High Availability
 
GSoC2014 - Uniritter Presentation May, 2015
GSoC2014 - Uniritter Presentation May, 2015GSoC2014 - Uniritter Presentation May, 2015
GSoC2014 - Uniritter Presentation May, 2015
 
Drupal MySQL Cluster
Drupal MySQL ClusterDrupal MySQL Cluster
Drupal MySQL Cluster
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016
 

Viewers also liked

Viewers also liked (20)

Office2007
Office2007Office2007
Office2007
 
ヒーロー島で起きた悲劇
ヒーロー島で起きた悲劇ヒーロー島で起きた悲劇
ヒーロー島で起きた悲劇
 
Apresentação ORCID Jornadas FCCN 2014 Évora
Apresentação ORCID Jornadas FCCN 2014 ÉvoraApresentação ORCID Jornadas FCCN 2014 Évora
Apresentação ORCID Jornadas FCCN 2014 Évora
 
Aiborgj0
Aiborgj0Aiborgj0
Aiborgj0
 
W杯2010のこれまで
W杯2010のこれまでW杯2010のこれまで
W杯2010のこれまで
 
Weird intersection
Weird intersectionWeird intersection
Weird intersection
 
Exploration lan switching_chapter1
Exploration lan switching_chapter1Exploration lan switching_chapter1
Exploration lan switching_chapter1
 
A Holistic Approach to Institutional ORCID Implementation
A Holistic Approach to Institutional ORCID ImplementationA Holistic Approach to Institutional ORCID Implementation
A Holistic Approach to Institutional ORCID Implementation
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Marshall Intro09
Marshall Intro09Marshall Intro09
Marshall Intro09
 
Open-V
Open-VOpen-V
Open-V
 
Partner Training: Nonprofit Industry
Partner Training: Nonprofit IndustryPartner Training: Nonprofit Industry
Partner Training: Nonprofit Industry
 
Ampower Corporate Presentation
Ampower Corporate PresentationAmpower Corporate Presentation
Ampower Corporate Presentation
 
Social media in schools
Social media in schoolsSocial media in schools
Social media in schools
 
ABA Eastern Europe
ABA Eastern EuropeABA Eastern Europe
ABA Eastern Europe
 
Midkiff Horse Training Demonstration
Midkiff Horse Training DemonstrationMidkiff Horse Training Demonstration
Midkiff Horse Training Demonstration
 
Horse and Mulepower
Horse and MulepowerHorse and Mulepower
Horse and Mulepower
 
Work with PFB Worldwide
Work with PFB Worldwide Work with PFB Worldwide
Work with PFB Worldwide
 
Social Media Extravaganza for Nonprofits
Social Media Extravaganza for NonprofitsSocial Media Extravaganza for Nonprofits
Social Media Extravaganza for Nonprofits
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
 

Similar to Using LuaJIT in mid-load web-projects

Workflow Engines for Hadoop
Workflow Engines for HadoopWorkflow Engines for Hadoop
Workflow Engines for HadoopJoe Crobak
 
Matrix, The Year To Date, Ben Parsons, TADSummit 2018
Matrix, The Year To Date, Ben Parsons, TADSummit 2018Matrix, The Year To Date, Ben Parsons, TADSummit 2018
Matrix, The Year To Date, Ben Parsons, TADSummit 2018Alan Quayle
 
Directories for the REST of Us: REST to LDAP in OpenDJ 2.6
Directories for the REST of Us: REST to LDAP in OpenDJ 2.6Directories for the REST of Us: REST to LDAP in OpenDJ 2.6
Directories for the REST of Us: REST to LDAP in OpenDJ 2.6ForgeRock
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Railselliando dias
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP LondonRicard Clau
 
Sanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansSanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansPeter Clapham
 
SSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJSSSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJSEugene Lazutkin
 
Troubleshooting Hadoop: Distributed Debugging
Troubleshooting Hadoop: Distributed DebuggingTroubleshooting Hadoop: Distributed Debugging
Troubleshooting Hadoop: Distributed DebuggingGreat Wide Open
 
Linux Distribution Collaboration …on a Mainframe!
Linux Distribution Collaboration …on a Mainframe!Linux Distribution Collaboration …on a Mainframe!
Linux Distribution Collaboration …on a Mainframe!All Things Open
 
A brief intro to nodejs
A brief intro to nodejsA brief intro to nodejs
A brief intro to nodejsJay Liu
 
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Adam Dunkels
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterJohn Adams
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoPaul Withers
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experienceAlex Tumanoff
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experienceIgor Anishchenko
 
CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development LetsConnect
 

Similar to Using LuaJIT in mid-load web-projects (20)

Workflow Engines for Hadoop
Workflow Engines for HadoopWorkflow Engines for Hadoop
Workflow Engines for Hadoop
 
Be faster then rabbits
Be faster then rabbitsBe faster then rabbits
Be faster then rabbits
 
Matrix, The Year To Date, Ben Parsons, TADSummit 2018
Matrix, The Year To Date, Ben Parsons, TADSummit 2018Matrix, The Year To Date, Ben Parsons, TADSummit 2018
Matrix, The Year To Date, Ben Parsons, TADSummit 2018
 
Directories for the REST of Us: REST to LDAP in OpenDJ 2.6
Directories for the REST of Us: REST to LDAP in OpenDJ 2.6Directories for the REST of Us: REST to LDAP in OpenDJ 2.6
Directories for the REST of Us: REST to LDAP in OpenDJ 2.6
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Rails
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
 
Sanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansSanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticians
 
Flexible compute
Flexible computeFlexible compute
Flexible compute
 
SSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJSSSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJS
 
Troubleshooting Hadoop: Distributed Debugging
Troubleshooting Hadoop: Distributed DebuggingTroubleshooting Hadoop: Distributed Debugging
Troubleshooting Hadoop: Distributed Debugging
 
Introduction to multicore .ppt
Introduction to multicore .pptIntroduction to multicore .ppt
Introduction to multicore .ppt
 
The Java Story
The Java StoryThe Java Story
The Java Story
 
Linux Distribution Collaboration …on a Mainframe!
Linux Distribution Collaboration …on a Mainframe!Linux Distribution Collaboration …on a Mainframe!
Linux Distribution Collaboration …on a Mainframe!
 
A brief intro to nodejs
A brief intro to nodejsA brief intro to nodejs
A brief intro to nodejs
 
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and Domino
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
 
Overview of PaaS: Java experience
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
 
CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development
 

Recently uploaded

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Using LuaJIT in mid-load web-projects

  • 1. Using LuaJIT in mid-load web-projects Alexander Gladysh CTO, LogicEditor
  • 2.
  • 3. On Lua and LuaJIT Lua: • powerful, • fast, • lightweight, • extensible, • embeddable scrip ng programming language.
  • 4. Language On Lua and LuaJIT • Origins. • Popularity growth. • Where is Lua used? • LuaRocks.
  • 5. Popular Dialects On Lua and LuaJIT • Lua 5.1 vs. Lua 5.2, • LuaJIT 2.0, • Metalua.
  • 6. LuaJIT 2.0 On Lua and LuaJIT • JIT, FFI, performance. • Limita ons on x86 64. • LuaJIT vs. Lua 5.2.
  • 7. Why Lua? On Lua and LuaJIT Historically: We're coming from computer games industry, where Lua "rules the world". Pragma cally: • Works fast! • Pleasant to code! • Easy to learn!
  • 8. Where to get programmers? On Lua and LuaJIT Reeduca on.
  • 9. Main problems learning Lua On Lua and LuaJIT • Mindless nkering with the language. • NIH-syndrome. Lua is to easy to nker with. • Diverging from the mainstream. Costs and benefits. • Language idiosyncrasies: • Global variables by default. • Arrays are indexed from 1. • Size of array with nil element is not defined. • Everything that is not nil or false — true (0 too).
  • 10. Most important! On Lua and LuaJIT When you code in Lua — code in Lua!
  • 11. Lua / LuaJIT place in your stack On Lua and LuaJIT First and foremost: • User-configurable business-logic. • Code that would otherwise be wri en in C/C++/OCaml.
  • 12. Frameworks to build webservices with Lua Our stack Some of the popular ones: • Kepler/WSAPI • OpenResty • Luvit We have a "bicycle", built on WSAPI.
  • 13. What web-problems are we solving with Lua? Our stack • Browser and social games. • Ad networks. • Other web-services, mobile games etc.
  • 15. OS Our stack • Xen XCP on top of Ubuntu Sever. • domU on Ubuntu Server: • HTTP frontends (nginx). • HTTP backends (32-bit). • Workers (32-bit). • DB (Redis, MySQL). • Aux (Bind, nginx-based config-server, deployment, monitoring etc.).
  • 16. Backends Our stack • nginx • spawn-fcgi + mul watch • LuaJIT 2.0 • FCGI/WSAPI • Applica on code
  • 17. Workers Our stack • runit • LuaJIT 2.0 • Applica on code
  • 18. IPC Our stack • ØMQ • Tasks: • Replacement for broken signals. • In-process cache reset. • (Workers get tasks via Redis.)
  • 19. System tuning Our stack • OS • bit.ly/kernel-magic (for frontends and backends) • Redis • I/O Scheduler: noop on guests, deadline on host • nginx • worker rlimit nofile
  • 20. "DevOps" Our stack • Deployment • High Availability • Monitoring
  • 21. Main libraries Our stack • lua-nucleo, lua-aplicado (be er — Penlight, telescope) • slnunicode • luatexts, luajson • luasocket, luaposix (be er — ljsyscall) • WSAPI • lua-zmq • lua-hiredis (be er — ljffi-hiredis) • luasql-mysql
  • 22. DSL and code genera on Our stack • HTTP request handlers. • Code (par ally sta cally validated). • Docs. • (Planned) Smoke-tests. • SQL schema. • "ORM" wrapper code. • DB schema patches. • Auto-backoffice. • Docs. • bit.ly/lua-dsl-talk • Common parts of a project are generated from text templates.
  • 23. Performance Our stack • About 160M synthe c hits per day per EX6-class server in ad networks. • About 8K simultaneous ac ve users per EX6-class server in online games.
  • 24. What did we encounter? Pi alls In main: • Couple "mysterious" problems, due to bugs in early LuaJIT2 betas (all fixed by now). • Problems, caused by two versions of the same LuaRocks package installed in the system. • Exploding Redis. • Lousy Hetzner HDD reliability.
  • 25. Diagnos cs, debugging and monitoring Pi alls • Par al sta c code valida on. • Run me valida on. • Autotests. • GC tuning and monitoring. • Monitoring for request mes, memory usage etc. • Debugging with logs.
  • 26. Main unsolved problems Pi alls • Long polling / Comet. • OS signal handling. • More efficient CPU usage with HTTP handlers. • LuaRocks: • Can install two versions of the same rock in the system. • Can't upgrade a package.
  • 27. Next genera on stack • Unblocking API with corou nes, no callback. Get inspired by, or adapt OpenResty. • Complete transi on to LuaJIT FFI. • Consider dropping LuaRocks. • Drop FCGI, move to epoll and lua-h p-parser. • Simplify the architecture as much as possible. Drop the configura on server. More code genera on! • New DSL design.
  • 28. Want to know more? Official Site lua.org, luajit.org Wiki lua-users.org/wiki, wiki.luajit.org Mailing Lists lua.org/lua-l.html, luajit.org/list.html StackOverflow stackoverflow.com/ques ons/tagged/Lua IRC #lua at irc.freenode.net