Wednesday, October 7, 2015

Erlang Misc



What are the advantages of Erlang over other programming languages?
Lightweight user-space threads.
Built-in distribution and failure detection.
Mostly functional programming with decent matching constructs, but with fully dynamic typing.
Reliability-oriented standard library.
Hot code swapping.

There's a lot of runtime introspection above and beyond hot code swapping. You can attach a console to a running node and inspect and modify state interactively.  I'm a big fan of debugging with printfs, but if you've got a stateful server in production and you want to debug it, it's a lot easier to connect using a real REPL shell than with say gdb.

Erlang has an excellent platform that rivals and in some cases, exceeds, the JVM. The BEAM VM is excellent. Since processes have a per-process heap, garbage collection pauses are greatly reduced compared to HotSpot. The library contains support for operational functionality like exposing SNMP traps and gauges.

A well tested garbage collector (acceptable "soft real time" performance) and the operational features make Erlang an excellent platform for long running services (as opposed to short running services, such as web application request handlers running as pre-spawned processes with mod_php/mod_perl/mod_python under Apache).

the language makes it easy to build a system out of single purpose actors that communicate only via immutable message passing. The language also makes it easy to build systems that can have isolated subsystems that can crash without bringing the whole system down and be restarted without intervention. Single assignment makes it very easy to reason locally. First class functions make it easy to write programs as a series of small functions that operate on both data and functions as data. It makes it easier to write distributed systems because you are already just sending messages to actors so they might just end up living on a different machine.

The language makes it hard to use shared mutable data structures that require locks, it makes it hard to crash the whole vm because of a single bug, it makes it hard to write confusing large functions where a single variable takes on many meanings, it makes it hard to write imperative loops without clear invariants (because there are no loops and recursive functions with argument pattern matching makes invariants obvious).

Erlang is a functional language, implementing the actor model for concurrency.
»The Actor model adopts the philosophy that everything is an actor. This is similar to the everything is an object philosophy used by some object-oriented programming languages, but differs in that object-oriented software is typically executed sequentially, while the Actor model is inherently concurrent.«


 we depend on the system Python on Linux and OS X and use py2exe to build executables for Windows

https://news.ycombinator.com/item?id=7277797
http://blog.erlware.org/some-thoughts-on-go-and-erlang/

https://blog.discordapp.com/scaling-elixir-f9b8e1e7c29b


While Discord is rich with features, most of it boils down to pub/sub. Users connect to a WebSocket and spin up a session process (a GenServer), which then communicates with remote Erlang nodes that contain guild (internal for a “Discord Server”) processes (also GenServers). When anything is published in a guild, it is fanned out to every session connected to it.

When a user comes online, they connect to a guild, and the guild publishes a presence to all other connected sessions.


Eventually we ended up with many Discord servers like /r/Overwatch with up to 30,000 concurrent users. During peak hours, we began to see these processes fail to keep up with their message queues. At a certain point, we had to manually intervene and turn off features that generated messages to help cope with the load

http://www.ostinelli.net/boost-message-passing-between-erlang-nodes/

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts