Wednesday, March 22, 2017

NGNIX vs Apache vs Node

Architectural decisions are always hard to make but the most crucial ones when it comes to server architecture and technology selection. This article is meant to make few of them a bit simpler.

Let us compare Apache, NGNIX and Node and help everyone give an insight to make a right decision.

Apache and Nginx are both HTTP servers. They can serve static files like (.jpg and .html files) or dynamic pages (like a Wordpress blog or forum written in a language like Java, PHP or Python). Apache/nginx need to be configured to recognize the URLs that users will be requesting and route them to the right place.

So, for example, with a typical Java Application you tell Apache that any file that ends with .jsp should be interpreted as Java code, so when the user visits "", for example, Apache will launch the Java interpreter (JVM) to read the file and process it. As part of this process, Java Controller may talk to a MySQL database and use that to generate the page. Lastly, Tomcat Container gives the final Java Embeded HTML Code to Apache to send to the user's browser.

Sounds simple correct?

Now, Node is a bit different. It's a programming environment like PHP that lets you talk to database, make dynamic pages, etc. However, it differs in that it includes an HTTP server. That means that it can actually act completely on its own without nginx or Apache. You can just run Node and it will be the HTTP server and also the "app server" (which actually creates your dynamic pages and talks to the DB).

It's bullseye deal !
Now let us get into more in detail of each one of them and compare them.
Apache's architecture simplicity :
Apache debuted in 1995 and in those days the web pages were very simple and the traffic was very low.
Apache's architecture was pretty simple for each new request a new process of correct type was spawned to handle the HTTP connection. The process would receive the request, process the request, make a response and return the response. The architecture was pretty simple and apache adopted it, there was very big downside to it we will discuss it in next paragraph. To make the process of spawning faster apache adopted a prefork model a number of processes were pre-spawned and they would process the HTTP connection as soon as the requests were made.
So each request was handled by a separate process but by 2005 the web traffic was increasing at a very high rate and the web pages were becoming more and more complex and to decrease the web page load time what was earlier a single request to the server was broken down into multiple requests and each request was made in parallel so that the resources could be downloaded in parallel and moreover browser would keep these connections open using keep-alive header. So apache's basic architecture of one process for one request soon started to consume the entire memory and crash.
Nginx :
NGINX was written specifically to address the performance limitations of Apache web servers. It was created in 2002 by Igor Sysoev, a system administrator for a popular Russian portal site (, as a scaling solution to help the site manage greater and greater volumes of traffic. It was open sourced in October 2004.
The success of Nginx is attributed to its architecture. Nginx follows an asynchronous event driven model for handling requests. Each worker can handle number of requests.
Question is what is event based model and what is relation of event based model with a worker handling multiple number of request ?
So suppose hypothetically we have only one worker on the nginx server. So nginx server maintains a queue for all the requests. It picks up the request if no I/O is required for that request it does the processing and returns the request with a response.
If the request has an I/O the a process is spawned for it at this point asynchronous behaviour and event driven behaviour comes into picture. The web worker does not waits for I/O to complete it moves to next request. What happens to the I/O the I/O on completion fires an event of completion and its callback is placed in queue for execution.
So in this way one web worker is able to handle multiple number of requests and generally on Nginx server there are number of workers or processes.
Node.js :
What JVM is to java, node.js is to javascript. It allows us to use javascript as a language for scripting on servers.
Ryan Dahl creator of Node.js was impressed by Nginx and looked at javascript which was made with asynchronous and event based model. He used google V8 engine which is used in chrome to process Javascript and created Node.js.

Monday, May 9, 2016

iBeacon is a protocol and Beacons are Devices

iBeacon and Beacons

Get the basics

iBeacon is a protocol developed by Apple and introduced at the Apple Worldwide Developers Conference in 2013. 

Several vendors have since made iBeacon-compatible hardware transmitters - typically called beacons - a class of Bluetooth low energy (LE) devices that broadcast their identification to nearby portable electronic devices such as smartphones,tablets, etc. These devices in turn perform specific actions based on the identification they receive.

Applications in the healthcare, fitness (FitBit is an example), beacons, security, and home entertainment industries are based on iBeacon Bluetooth Low Energy technology.

Beacons transmit a UUID(Universally Unique Identifier) picked up by a compatible app or operating system. The identifier and several bytes sent with it can be used to determine the device's physical location, track customers, or trigger a location-based action on the device such as a check-in on social media or a push notification.

Power Consumption

The Bluetooth LE protocol is significantly more power efficient than Bluetooth Classic. Several chipsets makers now supply chipsets optimized for iBeacon use. Power consumption depends on iBeacon configuration parameters of advertising interval in ms and transmit power. A study on different iBeacon vendors reports that battery life can range between 1–24 months. Apple's recommended setting of 100 ms advertising interval with a coin cell battery provides for 1–3 months of life, which increases to 2–3 years as advertising interval is increased to 900 ms.
Battery consumption of the phones is a factor that must be taken into account when deploying beacon enabled apps. A recent report has shown that older phones tend to draw more battery in the vicinity of iBeacons, while the newer phones can be more efficient in the same environment. An energy efficient iBeacon application needs to consider these aspects in order to strike a good balance between app responsiveness and battery consumption.

Use cases

Today’s mobile technology advancements are the key. With branded mobile apps coupled with location-based mobile technologies, you can create a compelling, satisfying, and exciting customer experience in ways not possible just a few months ago.

 • Surprise and delight customers with personalized welcome messages, promotions and discounts as they arrive at your stores.
 • When shoppers approach a new in-store display, automatically trigger pop-up videos, coupons or other information related to the merchandise.
• Help shoppers navigate the store with turn-by-turn directions so they can find what they’re looking for and not leave empty-handed.
• Engage shoppers when they are not at the store and encourage them to come back.

Wohooo Google is also into iBeacon comparison and much better

Apple’s iBeacon technology and Google’s Eddystone is this: iBeacon can only communicate with apps, whereas Eddystone works across apps and browsers

It would be interesting to see how the world will been changing their routes around IoT and Beacons will play a significant role in proximity based search and notification. 

Feel free to post your valuable comments in form of feedback and questions for me to answer.

Friday, November 6, 2015

Send Email Using Java Mail API

Lot you might find this post really handy as it has been so many instances that you find one or the other issues with the email sending using Java Mail API. Following code is working perfectly fine with no errors. Please replace placeholders with your concerned credentials, sender and recipients. Do not forget to download mail.jar and activation.jar which are part of Java Mail API and Activation framework. 

Just make sure you check the credentials you are providing for authentication have following things enabled under URL :

1. Enable "Allow less secure apps"
2. 2-Step Verification Off

import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

class SendEmail{

        public static void main(String args[]){
// Sending email start
// Recipient's email ID needs to be mentioned.
      String to= ""; 

      // Sender's email ID needs to be mentioned
      String from = "";

      // Assuming you are sending email from Gmail
      Properties props = new Properties();
props.put("", "");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");

Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("email_address","password");

         // Create a default MimeMessage object.
         Message message = new MimeMessage(session);

         // Set From: header field of the header.
         message.setFrom(new InternetAddress(from));

         // Set To: header field of the header.
         message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

         // Set Subject: header field
         message.setSubject("This is the Subject Line!");

         // Now set the actual message
         message.setText("This is actual message");

         // Send message
         System.out.println("Sent message successfully....");
      }catch (MessagingException mex) {


Feel free to contact me in case of any issues and queries. 

Thursday, April 23, 2015

Mobile Doctors and Facilities

MobiDoc : Solution towards Quicker and Healthy Living

  • Having sever pain in back and neck and we don't know whom to approach. Which physiotherapist lives near by and is available ?
  • Having small health issues with a kid and don't know which Pediatrician to approach who can consult at home?
  • Help required from Dietician or Nutritionist at home would be great?
  • Anyone new to the city and don't know who would be the best doctor fit to treat you and/or your family. 
  • Blood test or any other possible physical test which can be done at home. 

MobiDoc is a solution to all of the above problems. 

Boon for all patients to get connected to Medical Community on Demand. 

Boon to all Doctors to stay connected to other Doctors and patient community. 

Whomsover thinks this is innovation and serves current problems, please cast your vote and if interested to be a member of this community, kindly enroll your name and contact details, we will contact you. 


Tuesday, November 4, 2014

Real Time Projects on Emerging Technologies for IT/CSE Students

Every student reaches this state sooner or later where where they dive deep ONLY ONCE to figure out which project they must come up for their minor subjects or last year Project training.

As a student, we all know that this would be the first feather (The only possible game changer during the phase of interviews) on our empty crown (Resume). Well this sounds to be history for me, but trust me my readers, I have been in this phase with a lot more drama, where we found no online help nor an industry expert help.

We picked on a Research Topic those days and a buzz word as well "Steganography" which is nothing but an Art Of Hiding The Fact That Information is Hidden. Sounds interesting and developing the system out of just knowing the buzzwords was even more challenging. We did it.

This post is intended to be more of a quick guide on Real Time Projects on Emerging Technologies like Cloud Computing, Big Data, Mobile Apps and ECommerce.  Big Data is its foot marks in every project wherein data quantum is humongous and data sparsity problem needs to be resolved.

  1. VAAS (Video As A Service)
  2. Mobile Social TV on Cloud
  3. TST (Threshold Based Similarity Transitivity Method) on Cloud
  4. WSN to Cloud to Data Mining (Traffic Tracking System)
  5. Cloud Management Services (Live Example Amazon Cloud Console)
  6. Image Processing ECommerce Store
  7. Ecommerce for Creative Sellers and Buyers
  8. Mobile App for Live Streaming of a Club Event (video streaming by stream servers like UMedia server)
  9. AES Secured Hypervisor on Cloud
  10. Health Care on Cloud
  11. Campaign Monitor Problem - Big Data
  12. Leaders Poll- Big Data/Cloud
  13. Sales Recommendation System
I hope the above list would help lot of you who love challenges and bringing the strongest out of you!