A brief description of OTP in Erlang and a brief description of ErlangOTP
OTP contains a set of libraries and implementation methods to build large-scale, fault-tolerant, and distributed applications. It contains many powerful tools to implement H248, SNMP, and other protocols, the core concept is OTP behavior. It can be seen as an application framework that uses callback functions as parameters, similar to a J2EE container. The callback function is responsible for solving the non-function part of the problem.
The gen_server module can be used to exchange things and hot code,
1) determine the callback Module name
2) compile interface functions
3) write 6 required callback functions in the callback module.
When a server crashes, a mechanism is required to detect and restart the server. A monitoring tree is used to create a monitor to manage the server. There are two types of monitoring trees: one-to-one and one-to-many.
$ Erl-boot start_sasl
Creates an environment for running the production System. The System architecture Support library (SASL, System Administration Support Libriaries) will be responsible for error records and overload protection.
Using gen_server, gen_supervisor, application and other behaviors, you can build a system with a reliability of 99.9999999.
Unified erlang message:
1) abstracts the differences between different line protocols
2) the Erlang message does not need to be parsed. The receiving process does not need to parse the message before processing, and the http server must parse all the messages received.
3) Erlang messages can contain data types of any complexity. http messages must be serialized to a flattened level before they can be transmitted.
4) Erlang messages can be transmitted between different processors
Common third-party libraries include rebar (https://github.com/basho/rebar) and cowboy (https://githun.com/extend/cowboy ). Rebar is the de facto standard for managing erlang projects. You can use rebar to create new projects, compile projects, package them, integrate them with other projects, and integrate github. Cowboy is a high-performance web server written in erlang and is a hot Implementation of Embedded web. In addition, the encoding and decoding methods of library mochiweb2 (http://github.com/mochi/mochiweb) can realize mutual conversion between json strings and erlang data types.
The Erlang program runs on a multi-core CPU.
1) use a large number of processes
2) avoid side effects, such as not using shared ETS or DETS
3) To avoid sequential bottlenecks, you can use pmap instead of map.
4) Small messages, large computing
5) Use mapreduce to make computing parallel
Mapreaduce is a parallel high-level function. Its definition is as follows:
-Specmapreduce (F1, F2, Acc0, L)-> Acc
F1 = fun (Pid, X)-> void
F2 = fun (Key, [Value], Acc0)-> Acc
L = [X]
Acc = X = term ()
Mapreduce is defined in the parallel High-Order Function (phofs) module.