SlideShare a Scribd company logo
1 of 26
Download to read offline
Erlang at Nu Echo
Some lessons learned
Dominique BoucherDominique Boucher
Nu Echo
Agenda
Who we are, what we doWho we are, what we do
NuGram Hosted Server
Why Erlang
Architecture
Some lessons
Who we are / what we do
• Speech applicationsSpeech applications
experts
Lots of R&D• Lots of R&D
• Many tools to
support our own practice
• Grammar tools
• Benchmarking/tuning tools
• Testing/monitoring toolsTesting/monitoring tools
Some of our tools
NuBot
NuGram IDE
NuGram Hosted Server
Hosted infrastructure for deploying andHosted infrastructure for deploying and
sharing speech grammars
– Supports static AND dynamic grammars– Supports static AND dynamic grammars
– Embeds the NuGram technologies
• Dynamic grammar instantiation• Dynamic grammar instantiation
• Grammar conversion to ABNF/GrXML/GSL
• Text-based semantic interpretationp
• To complement telephony in the cloudTo complement telephony in the cloud
(eg. Tropo)
NuGram Hosted Server
Components
RESTf l API– RESTful API
– www.grammarserver.com/api
C it b it– Community website
– www.grammarserver.com
– NuGram product website
– nugram.nuecho.com
NuGram Hosted Server
NuGram
Hosted Server
Your application
(Java Ruby PythonHosted Server (Java, Ruby, Python,
JavaScript, Erlang, etc.)
Telephony
Platform
NuGram Hosted Server
An example in Ruby
dyngrammar = "#ABNF 1.0 UTF-8;
...
"
server = GrammarServer.new()
session = server.create session("username", "passwrd")session server.create_session( username , passwrd )
session.upload("digits2.abnf", dyngrammar);
grammar = session.instantiate("digits2.abnf", {})
interpretation
i t t(' t th f ') t j= grammar.interpret('one two three four').to_json
session.disconnect
Why Erlang?
• Initial requirementsInitial requirements
• High-performance HTTP server
• Scalability Fault tolerance• Scalability, Fault-tolerance
• Hot code swapping
Di t ib t d d t b• Distributed database
• The Erlang appeal
• Single language, single platform
• Ideal projectp j
• for experimenting with a different technology
Components
• Behaviours for building robust
applications
• Behaviours for building robust
applications
OTP
(Open Telecom
Pl tf ) applicationsapplicationsPlatform)
• High performance HTTP Server• High performance HTTP ServerYaws • High-performance HTTP Server• High-performance HTTP ServerYaws
• Distributed, fault-tolerant, soft
realtime DB
• Distributed, fault-tolerant, soft
realtime DB
Mnesia
• Java API to expose Java/Kawa
code as a regular Erlang node
• Java API to expose Java/Kawa
code as a regular Erlang node
Jinterface
High-level architecture
JInterface JInterface JInterface
www.grammarserver.com
(http + https)
Yaws
nugram.nuecho.com
(http + https)
Y
MnesiaRESTful API
(http + https)
Session handling
Java/Kawa Worker
Java/Kawa Worker
Java Thread
Erlang Node
Ja a ead
Session
Dispatcher
Mnesia
Yaws
Dispatcher
Request Response
Session handling
Java/Kawa Worker
Java/Kawa Worker
Java Thread
Erlang NodeErlang Node
Ja a ead
cated)
Session
cated)
Dispatcher
sia(replic
DispatcherDispatcher
sia(replic
Yaws
Dispatcher
Mnes
Yaws
Dispatcher
Yaws
Dispatcher
Mnes
Request Response
Session handling
• Sending messages to remote nodes isSending messages to remote nodes is
completely transparent
E l ( i lifi d)Example (simplified)
Process = db:get session(SessionID)Process = db:get_session(SessionID),
Process ! Request.
Session handling
• Session timeouts handled by theSession timeouts handled by the
session process
E lExample
receive
…
after Timeout ->
db:expire_session(self())
end
Mnesia
• StoresStores…
• User accounts
• All grammars
(templates and instantiated ones)
• Node IDs of all Java workers
• All session data
What we’ve developed
Account management
Registration, email confirmation, etc.
BBcode validation & conversion for comments
Twitter widget
A process caches the tweetsA process caches the tweets
and updates it every 5 minutes
Rendering of tweetse de g o ee s
RSS reader / widget
A process caches the feed contentA process caches the feed content
and updates it every hour
What we’ve developed
Code-based representationp
of the web site structure
Tree like structureTree-like structure
Documents, modules, sections
Supports the addition on new “modules”
Lots of unit tests!
Web site structure
-define(SITE_CONFIGURATION,
{ i d{section, "product_app", "Home",
[{module, "welcome",
"Welcome - NuGram Platform",
{nugram_site, welcome_with_news, []}},
{document, "system_error",
"Warning - Request not completed",
"system_error.html"},
{section, "nugram_platform", "NuGram Platform",
[{document, "overview",
"Overview",
"nugram_overview.html"},
{document, "faq", "FAQ", "faq.html"},{ , q , , q },
{document, "abnf_tutorial",
"Grammar Language Tutorial",
"abnf_tutorial.html"},
……
Lessons learned
• Erlang strengths
• Glueing things togetherg g g
• Data transformations
• bbcode XML• bbcode, XML
• Protocol handling / processing byte
streamsstreams
• Like encoding detection
G t d i d l t i t• Great dynamic development environment
• REPL + connecting to a running node
Lessons learned
E l k• Erlang weaknesses
• Sequential computations
harder to express
• A matter of style
• String manipulationg p
• Somewhat better now (support for encodings)
Lessons learned
• Learn and use OTP
from day one
• Servers,
supervisors,
applicationsapplications
• Worth the investment
E l t itt f d• Example: twitter feed server
• First version without OTP
crashed way too often making the platform unreliable• crashed way too often, making the platform unreliable
• Second version using gen_server
Lessons learned
• Dynamically-typed languages makeDynamically typed languages make
non-trivial refactorings difficult and
error-proneerror-prone
• Not specific to Erlang,
b t litbut a reality
• Dializer can help
• Hot code loading is greatHot code loading is great
• But tricky to do right
Lessons learned
• Know your toolsKnow your tools
• Toolbar, tv,
appmon, pmanpp , p
D 't i t th h l• Don't reinvent the wheel
• There are a lot more libraries now
• we use Yaws, oauth, smtp_fsm
• rebar - great build tool
We learned a lot!
And we had a lot of fun()!()
halt()halt().

More Related Content

What's hot

Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
Tomas Doran
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey Morenets
Alex Tumanoff
 
Flickr Architecture Presentation
Flickr Architecture PresentationFlickr Architecture Presentation
Flickr Architecture Presentation
eraz
 
Spark SQL Catalyst Optimizer, Custom Expressions, UDFs - Advanced Spark and T...
Spark SQL Catalyst Optimizer, Custom Expressions, UDFs - Advanced Spark and T...Spark SQL Catalyst Optimizer, Custom Expressions, UDFs - Advanced Spark and T...
Spark SQL Catalyst Optimizer, Custom Expressions, UDFs - Advanced Spark and T...
Chris Fregly
 
Navigating the Incubator at the Apache Software Foundation
Navigating the Incubator at the Apache Software FoundationNavigating the Incubator at the Apache Software Foundation
Navigating the Incubator at the Apache Software Foundation
Brett Porter
 

What's hot (20)

Go Deep
Go DeepGo Deep
Go Deep
 
Serialization (Avro, Message Pack, Kryo)
Serialization (Avro, Message Pack, Kryo)Serialization (Avro, Message Pack, Kryo)
Serialization (Avro, Message Pack, Kryo)
 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the Wild
 
Multi-platform Enterprise Messaging with RabbitMQ
Multi-platform Enterprise Messaging with RabbitMQMulti-platform Enterprise Messaging with RabbitMQ
Multi-platform Enterprise Messaging with RabbitMQ
 
Planet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: BigdamPlanet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: Bigdam
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous Applications
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey Morenets
 
Technologies for Data Analytics Platform
Technologies for Data Analytics PlatformTechnologies for Data Analytics Platform
Technologies for Data Analytics Platform
 
From 100s to 100s of Millions
From 100s to 100s of MillionsFrom 100s to 100s of Millions
From 100s to 100s of Millions
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applications
 
Flickr Architecture Presentation
Flickr Architecture PresentationFlickr Architecture Presentation
Flickr Architecture Presentation
 
NRD: Nagios Result Distributor
NRD: Nagios Result DistributorNRD: Nagios Result Distributor
NRD: Nagios Result Distributor
 
Spark SQL Catalyst Optimizer, Custom Expressions, UDFs - Advanced Spark and T...
Spark SQL Catalyst Optimizer, Custom Expressions, UDFs - Advanced Spark and T...Spark SQL Catalyst Optimizer, Custom Expressions, UDFs - Advanced Spark and T...
Spark SQL Catalyst Optimizer, Custom Expressions, UDFs - Advanced Spark and T...
 
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
 
Scaling with Symfony - PHP UK
Scaling with Symfony - PHP UKScaling with Symfony - PHP UK
Scaling with Symfony - PHP UK
 
High Performance Computing - Cloud Point of View
High Performance Computing - Cloud Point of ViewHigh Performance Computing - Cloud Point of View
High Performance Computing - Cloud Point of View
 
Navigating the Incubator at the Apache Software Foundation
Navigating the Incubator at the Apache Software FoundationNavigating the Incubator at the Apache Software Foundation
Navigating the Incubator at the Apache Software Foundation
 
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...
 

Similar to Erlang at Nu Echo

Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
CIVEL Benoit
 

Similar to Erlang at Nu Echo (20)

A Practical Guide to Selecting a Stream Processing Technology
A Practical Guide to Selecting a Stream Processing Technology A Practical Guide to Selecting a Stream Processing Technology
A Practical Guide to Selecting a Stream Processing Technology
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testing
 
Whole Platform LWC11 Submission
Whole Platform LWC11 SubmissionWhole Platform LWC11 Submission
Whole Platform LWC11 Submission
 
Advanced Web Technology.pptx
Advanced Web Technology.pptxAdvanced Web Technology.pptx
Advanced Web Technology.pptx
 
Building the ideal betting stack | London Erlang User Group presentation
Building the ideal betting stack | London Erlang User Group presentationBuilding the ideal betting stack | London Erlang User Group presentation
Building the ideal betting stack | London Erlang User Group presentation
 
Venkata
VenkataVenkata
Venkata
 
Fastest Servlets in the West
Fastest Servlets in the WestFastest Servlets in the West
Fastest Servlets in the West
 
Hail hydrate! from stream to lake using open source
Hail hydrate! from stream to lake using open sourceHail hydrate! from stream to lake using open source
Hail hydrate! from stream to lake using open source
 
GAJENDRA_JAVA_J2EE_Profile
GAJENDRA_JAVA_J2EE_ProfileGAJENDRA_JAVA_J2EE_Profile
GAJENDRA_JAVA_J2EE_Profile
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
 
Highly concurrent yet natural programming
Highly concurrent yet natural programmingHighly concurrent yet natural programming
Highly concurrent yet natural programming
 
Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...
 
Tech talk microservices debugging
Tech talk microservices debuggingTech talk microservices debugging
Tech talk microservices debugging
 
soa
soasoa
soa
 
Server Monitoring (Scaling while bootstrapped)
Server Monitoring  (Scaling while bootstrapped)Server Monitoring  (Scaling while bootstrapped)
Server Monitoring (Scaling while bootstrapped)
 
Node.js Getting Started &amd Best Practices
Node.js Getting Started &amd Best PracticesNode.js Getting Started &amd Best Practices
Node.js Getting Started &amd Best Practices
 
Edward King SPEDDEXES 2014
Edward King SPEDDEXES 2014Edward King SPEDDEXES 2014
Edward King SPEDDEXES 2014
 

Erlang at Nu Echo

  • 1. Erlang at Nu Echo Some lessons learned Dominique BoucherDominique Boucher Nu Echo
  • 2. Agenda Who we are, what we doWho we are, what we do NuGram Hosted Server Why Erlang Architecture Some lessons
  • 3. Who we are / what we do • Speech applicationsSpeech applications experts Lots of R&D• Lots of R&D • Many tools to support our own practice • Grammar tools • Benchmarking/tuning tools • Testing/monitoring toolsTesting/monitoring tools
  • 4. Some of our tools NuBot NuGram IDE
  • 5. NuGram Hosted Server Hosted infrastructure for deploying andHosted infrastructure for deploying and sharing speech grammars – Supports static AND dynamic grammars– Supports static AND dynamic grammars – Embeds the NuGram technologies • Dynamic grammar instantiation• Dynamic grammar instantiation • Grammar conversion to ABNF/GrXML/GSL • Text-based semantic interpretationp • To complement telephony in the cloudTo complement telephony in the cloud (eg. Tropo)
  • 6. NuGram Hosted Server Components RESTf l API– RESTful API – www.grammarserver.com/api C it b it– Community website – www.grammarserver.com – NuGram product website – nugram.nuecho.com
  • 7. NuGram Hosted Server NuGram Hosted Server Your application (Java Ruby PythonHosted Server (Java, Ruby, Python, JavaScript, Erlang, etc.) Telephony Platform
  • 8. NuGram Hosted Server An example in Ruby dyngrammar = "#ABNF 1.0 UTF-8; ... " server = GrammarServer.new() session = server.create session("username", "passwrd")session server.create_session( username , passwrd ) session.upload("digits2.abnf", dyngrammar); grammar = session.instantiate("digits2.abnf", {}) interpretation i t t(' t th f ') t j= grammar.interpret('one two three four').to_json session.disconnect
  • 9. Why Erlang? • Initial requirementsInitial requirements • High-performance HTTP server • Scalability Fault tolerance• Scalability, Fault-tolerance • Hot code swapping Di t ib t d d t b• Distributed database • The Erlang appeal • Single language, single platform • Ideal projectp j • for experimenting with a different technology
  • 10. Components • Behaviours for building robust applications • Behaviours for building robust applications OTP (Open Telecom Pl tf ) applicationsapplicationsPlatform) • High performance HTTP Server• High performance HTTP ServerYaws • High-performance HTTP Server• High-performance HTTP ServerYaws • Distributed, fault-tolerant, soft realtime DB • Distributed, fault-tolerant, soft realtime DB Mnesia • Java API to expose Java/Kawa code as a regular Erlang node • Java API to expose Java/Kawa code as a regular Erlang node Jinterface
  • 11. High-level architecture JInterface JInterface JInterface www.grammarserver.com (http + https) Yaws nugram.nuecho.com (http + https) Y MnesiaRESTful API (http + https)
  • 12. Session handling Java/Kawa Worker Java/Kawa Worker Java Thread Erlang Node Ja a ead Session Dispatcher Mnesia Yaws Dispatcher Request Response
  • 13. Session handling Java/Kawa Worker Java/Kawa Worker Java Thread Erlang NodeErlang Node Ja a ead cated) Session cated) Dispatcher sia(replic DispatcherDispatcher sia(replic Yaws Dispatcher Mnes Yaws Dispatcher Yaws Dispatcher Mnes Request Response
  • 14. Session handling • Sending messages to remote nodes isSending messages to remote nodes is completely transparent E l ( i lifi d)Example (simplified) Process = db:get session(SessionID)Process = db:get_session(SessionID), Process ! Request.
  • 15. Session handling • Session timeouts handled by theSession timeouts handled by the session process E lExample receive … after Timeout -> db:expire_session(self()) end
  • 16. Mnesia • StoresStores… • User accounts • All grammars (templates and instantiated ones) • Node IDs of all Java workers • All session data
  • 17. What we’ve developed Account management Registration, email confirmation, etc. BBcode validation & conversion for comments Twitter widget A process caches the tweetsA process caches the tweets and updates it every 5 minutes Rendering of tweetse de g o ee s RSS reader / widget A process caches the feed contentA process caches the feed content and updates it every hour
  • 18. What we’ve developed Code-based representationp of the web site structure Tree like structureTree-like structure Documents, modules, sections Supports the addition on new “modules” Lots of unit tests!
  • 19. Web site structure -define(SITE_CONFIGURATION, { i d{section, "product_app", "Home", [{module, "welcome", "Welcome - NuGram Platform", {nugram_site, welcome_with_news, []}}, {document, "system_error", "Warning - Request not completed", "system_error.html"}, {section, "nugram_platform", "NuGram Platform", [{document, "overview", "Overview", "nugram_overview.html"}, {document, "faq", "FAQ", "faq.html"},{ , q , , q }, {document, "abnf_tutorial", "Grammar Language Tutorial", "abnf_tutorial.html"}, ……
  • 20. Lessons learned • Erlang strengths • Glueing things togetherg g g • Data transformations • bbcode XML• bbcode, XML • Protocol handling / processing byte streamsstreams • Like encoding detection G t d i d l t i t• Great dynamic development environment • REPL + connecting to a running node
  • 21. Lessons learned E l k• Erlang weaknesses • Sequential computations harder to express • A matter of style • String manipulationg p • Somewhat better now (support for encodings)
  • 22. Lessons learned • Learn and use OTP from day one • Servers, supervisors, applicationsapplications • Worth the investment E l t itt f d• Example: twitter feed server • First version without OTP crashed way too often making the platform unreliable• crashed way too often, making the platform unreliable • Second version using gen_server
  • 23. Lessons learned • Dynamically-typed languages makeDynamically typed languages make non-trivial refactorings difficult and error-proneerror-prone • Not specific to Erlang, b t litbut a reality • Dializer can help • Hot code loading is greatHot code loading is great • But tricky to do right
  • 24. Lessons learned • Know your toolsKnow your tools • Toolbar, tv, appmon, pmanpp , p D 't i t th h l• Don't reinvent the wheel • There are a lot more libraries now • we use Yaws, oauth, smtp_fsm • rebar - great build tool
  • 25. We learned a lot! And we had a lot of fun()!()