Comments
yourfanat wrote: I am using another tool for Oracle developers - dbForge Studio for Oracle. This IDE has lots of usefull features, among them: oracle designer, code competion and formatter, query builder, debugger, profiler, erxport/import, reports and many others. The latest version supports Oracle 12C. More information here.
Cloud Expo on Google News
SYS-CON.TV

2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
Effects of Omitting NODE_ENV in Express.js Apps By @DKhan | @DevOpsSummit #APM #DevOps
Environment variables are often used for distinguishing between environments like 'production,' 'staging' and 'development'

The Drastic Effects of Omitting NODE_ENV in Your Express.js Applications

Most developers learn best by examples, which naturally tend to simplify matters and omit things that aren't essential for understanding. This means that the "Hello World" example, when used as starting point for an application, may be not suitable for production scenarios at all.

I started using Node.js like that and I have to confess that it took me almost two years to quantify the huge performance impact of omitting a single environment variable. In fact it was just a coincidence that I even did it right in my previous projects.

Mind your environment
Environment variables are often used for distinguishing between environments like "production", "staging" and "development". Depending on those variables an application may turn debugging on or off, connect to a specific database, or listen on a specific port.

In Node.js there is a convention to use a variable called NODE_ENV to set the current mode.

For my Node.js projects I mostly use Express.js, a lightweight web application framework. If you look at its Hello World example you might think Express doesn't care about the mentioned NODE_ENV variable because there is no reference to it. However, a look at the source code tells a slightly different story. We see that it in fact reads NODE_ENV and defaults to ‘development' if it isn't set. This variable is exposed to applications via ‘app.get("env")' and can be used to apply environment specific configurations as explained above, but it's up to you to use this or not.

One strength of Node.js is its module ecosystem, and a typical application uses plenty of them. For Express I always at least install a template engine which can be easily added to a project. You see that there is no further configuration needed. It just works out-of-the-box. And basically this is where the trouble starts.

The hidden powers of NODE_ENV
While you might think that you are environment-agnostic by not using NODE_ENV or app.get(‘env'), Express takes care of that for you and will for instance switch the view cache on or off depending on your environment. This makes sense because you don't want to restart your app to clear the cache every time you change some markup. Consequently this also means that your views are parsed and rendered for every request in development mode. Do you remember that this is the default if you omit NODE_ENV?

In my applications I always used some conditions that relied on the "env" variable, so I launched them with something like NODE_ENV=<environment> node server.js. But what would happen if I didn't? Would there be a notable performance hit?

Let's test
I've created a little sample app that connects to a database, calls some external services and renders a page using Jade.

After instrumenting it using Dynatrace I ran several tests using theapache benchmarking tool (ab) like that: ab -c 100 -n 10000 http://<myhostname>:3000/

This means: open this webpage 10.000 times with a concurrency of 100.

Using Dynatrace Web I charted the number of requests versus CPU usage and the results were really stunning:

Figure 2: CPU Usage vs. Number of Requests

The green bars show the number of requests and the blue line represents the CPU usage. We clearly see that by setting NODE_ENV to production the number of requests Node.js can handle jumps by around two-thirds while the CPU usage even drops slightly.

Let me emphasize this: Setting NODE_ENV to production makes your application 3 times faster!

Click here for the full article

About Daniel Khan
Daniel Khan has over 15 years experience as full stack developer, architect and technical lead in the field of web engineering proving his strong problem solving skills in hundreds of projects. He is passionate about constant learning, using new technologies and sharing his findings with others. As technology strategist, Daniel focuses on driving support for emerging technologies like Node.js and MongoDB at Dynatrace.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Latest AJAXWorld RIA Stories
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is no...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to...
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need t...
"We're developing a software that is based on the cloud environment and we are providing those services to corporations and the general public," explained Seungmin Kim, CEO/CTO of SM Systems Inc., in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the ...
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – N...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE