Application code and the server configuration examples with file-system access, RAM state, database access and parallel asynchronous processing of different resource types by stateful and stateless API requests.
Rapid API development examples for Impress Application Server / Node.js (jsfwdays 2014)
1. Rapid API development examples for
Impress Application Server (Node.js)
Timur Shemsedinov
Research Institute of System Technologies (UA, Kiev), MetaSystems Inc.
mailto:timur.shemsedinov@gmail.com https://github.com/tshemsedinov/impress
http://habrahabr.ru/users/marcusaurelius/ https://www.npmjs.org/package/impress
2. Impress Application Server is:
• Scaling transparent to applications
• Application isolation (memory configuration database)
• Deployment or update code without restart
• Highload serving static files from memory (gzip, js minification, etc.)
• URL-rewriting using RegExp, with internal redirection or sending
external HTTP-requests (reverse proxying)
• Virtual hosts with multi-domain support (e.g.: *.domain.com)
• Executable code and static caching in RAM
• TCP port multiplexing and demultiplexing between applications
• Server-Sent Events and WebSocket support
• Stateless API (REST) and stateful API (RPC) support with IP-sticky
and Cookie-sticky to associated processes and global state sync.
• Many other features: sessions, rotating logging, IPC and ZeroMQ,
database access drivers, etc.
3. Rapid API development examples
General principles:
• Request routing based on file system
• Each handler in separate file, handler inherit/override mechanism
• Handlers need not prepare request execution environment, such as
import/load libraries, establish db connections, build memory
structures, etc., request will come to ready application environment
and handler will contain just applied code
• Each application have own isolated context and in-memory state
• Long and batch workers in separate threads (forking by Impress
Application Server into parallel processes)
• Global cross-server interprocess communication based on system
IPC and ZeroMQ to translate events, synchronize state, use reactive
approach and actor-pattern
19. Server installation (node.js + Impress)
CentOS 6.5 (64bit) minimal
curl http://.../impress/install.sh | sh
---------------------------------------------------------------
#!/bin/bash
yum -y update
yum -y install wget
yum -y groupinstall "Development Tools"
cd /usr/src
wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
tar zxf node-v0.10.26.tar.gz
cd node-v0.10.26
./configure
make
make install
ln -s /usr/local/bin/node /bin
ln -s /usr/local/bin/npm /bin
mkdir /impress
cd /impress
npm install impress
20. Application Server as Linux Daemon
If installing Impress into absolute path /impress
Run /impress/bin/install.sh for:
• Setup and configure as Linux daemon
• Run at system startup
• Auto-restart daemon workers on fails
Run /impress/bin/uninstall.sh for:
• Stop Application Server
• Remove from system startup
• Remove Daemon from system
After install as a service (daemon) you can use:
service impress start
service impress stop
service impress restart
service impress update
service impress status
29. Thanks for attention!
Questions please
Timur Shemsedinov
Research Institute of System Technologies (UA, Kiev), MetaSystems Inc.
mailto:timur.shemsedinov@gmail.com
http://habrahabr.ru/users/marcusaurelius/
https://www.npmjs.org/package/impress
https://github.com/tshemsedinov/impress