Friday, October 9, 2015

Hot Code Swapping



http://stackoverflow.com/questions/2968914/code-hot-swapping-in-erlang
Yes, hot swapping in erlang servers generally refers to this feature. It is well explained in the stackoverflow question Achieving code swapping in Erlang’s gen_server, and also in this neatErlang Generic Server tutorial or this little one.
The Erlang/OTP gen_server module provides a generic way to achieve hot swapping, by implementing a Module:code_change/3 function in the callback module.
This way, you can upgrade a servers code without shutting it down, or fall back to former implementation if something does not work as expected. In general, hot swap should be put in place using the generic release handler.
https://www.quora.com/How-does-hot-code-swapping-work
The object file/executable are replaced with the updated one, that's hot code swapping. In Java its done by replacing .class file in .jar. Since .jar is an archive only so we can push updated class files into it and the changes will be reflected immediately.Thus, not much of work in Java code.

In case of erlang, we have access to VM from erlang terminal, so we can edit code, compile and load updated executables. 

It can be done C/C++ also. But thats more of tedious task, Kernel Loadable Modules is the best example for C hot-code swapping. Its tedious in C/C++ because, after generating object files, the C/C++ compiler combines them into executables by resolving all dependencies, so depending on how we write the code, for ex the code is written in form of several shared objcets, replacing one with updated shared object should do the thing. Or we might need to develop framework handling the code swaping like its done in Linux Kernel for loading/unloading Custom modules.
https://www.quora.com/Erlang-programming-language/Is-it-possible-to-achieve-something-like-Erlang-hot-swap-in-other-PLs-platforms-without-interrupting-old-activities
Many server run the old and new version of code in parallel for a while, but only the new version receives new requests. That is a usual handling of a zero downtime policy. But most languages I know don't support that feature natively. Erlang and Elixir are the only languages in my portfolio having that

http://stackoverflow.com/questions/20262716/advanced-code-hot-swapping-in-jdk-8

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