Multithreaded Environment Vs Event Driven Environment Information Technology Essay
|✅ Paper Type: Free Essay||✅ Subject: Information Technology|
|✅ Wordcount: 2349 words||✅ Published: 1st Jan 2015|
If you need assistance with writing your essay, our professional essay writing service is here to help!Essay Writing Service
In 2010 Node had a turning point, and it’s shaping up to be as popular as Ruby on Rails among developers. Hardly few developers are working on this new technology which is shifting the way scalable web apps can be developed. Node.js, is being greeted as “the new Ruby on Rails” by some in the developer community. But it’s not a magic bullet, nor is it appropriate for all programming scenarios. The growth of Node.js is being sponsored by Joyent, an SF-based cloud software company. Ryan Dahl, who is creator of Node.js, is employee of this company. He is being continuously hosting events and creating tools for growing Node community. Recently, Then there’s the community. The Ruby community has been criticized for being exclusive and harsh. The Node community provides a welcome contrast and embodies the spirit of many other open-source communities.
Need of Node
Traditional Way of Doing Web I/O was wrong
Figure 1 – Traditional way of Web I/O
There was need of parallelism where web server can handle request in following way
Figure 2- Parallelized Web I/O
Why Choose Node?
There is no single framework or right language which is applicable for all web applications.
Node is based on event-driven programming. Event driven programming reduces actual amount of resources still you get a lot more out of those resources.
The main advantage of Node is its accessibility. Facebook’s chat server is being powered by Erlang, which uses same model as node. Tornado, Concurrent server for Python which support Friend Feed also works on same basis but accessibility is main advantage of Node over Erlang and Tornado since it uses Java script and java script which is very well known by people.
The node has changed the way I/O operations are done. Traditional languages and frameworks pre-allocates large amount of resources for each and every user. Thus communication between web server and database is most time-intensive portion. Node allocates web server resources on an on-demand basis thus leaving smaller footprints on web server side.
The node does not allocate resources to things when they are waiting and thus provides efficiency. For e.g., suppose that application wants to talk with database, and it’s going to take 100ms for responding. Instead of assigning resources and waiting for that call to respond, Node uses callback technique. When the database responds it allocates the resources required to process. This improves performance, because server is allocated to resources only when they need it and not while waiting on databases.
Event Driven Programming
Applications which uses with multiple i/o sources has been using multithreaded programming techniques for long.The main advantage of multithreaded techniques is that it allows applications to handle activities concurrently leading to efficient execution.
In case of web servers performing I/O operations parallel makes better use of available processors. Running threads in multicore system is very easy as each thread runs on separate core providing true parallelism. Single core system contains single processor that executes one thread, switches to other and executes it and so on. Switching takes place because completing I/O operation takes large number of processor cycles. Evan though many developers have taken advantage of multithreading programming environment most of them agree that it can sometime lead to problem that can be difficult separate and correct such as deadlock. Also multithreading environment is OS dependent as OS decided which thread should execute and for how much time thus loses developers control to some extent.
The event driven programming provides best alternative for developers and makes development of efficient, scalable systems easy. The model makes application to rely on event notifications.
An asynchronous I/O operation is key factor of event driven programming as it prevents application from getting locked until I/O operation finishes. Suppose that application want to write large amount data to socket. If the buffer gets filled application will have to wait until buffer space becomes available thus causing blocking I/O and preventing application from doing any other operations. If the socket writing is made no blocking , it send indication to application saying that further writing is currently not possible and application should try this after some time. Meanwhile application can perform other task. As application registers itself with event notification system it will receive notification once buffer space becomes available.
Event driven Programming model can also become problematic in following cases
Event notification is not applicable to all intercrosses communication approaches. For example, If two applications are communicating through shared memory or shared space, and shared space does not provide any handle for registering events.
Certain programming languages do not provide full support for asynchronous I/O as different actions are required for different context. For example C does not provide Anonymous functions thus developers will have to provide function each event and event context.
Multithreaded environment Vs. Event driven Environment
Multithreaded environment can be compared with Event driven environment on the basis of Food Restaurant analogy.
In thread-based model procedure would be getting to the front of the line, placing order and then wait in the queue until the order is cooked and given. Thus cahier would remain idle until the order is processed. In peak hours to service more customers the best way is to get more cashiers.
Fast food doesn’t work in this way. They use event-driven model in which they try to use same amount of cashiers effectively. Once the order is placed and it is sent off for processing customer will have to step aside after paying. Cashier can process next customer. In some restaurants pager is given which will flash or vibrate when order is ready for pick up. The key point is that you are not blocking the receiving of new orders. When your food is set, the cashier – or someone – will signal you by calling out your name, order number or triggering your pager. The event of your order being ready causes the person to perform some function/action. (In programming lingo, this would be thought of as a “callback function”.) You will then go up and get your food.
Web servers “Traditional mode” has always been using thread based model. Whenever Apache or any other web server is started it starts receiving connections. After receiving connection server holds that connection until the transaction is completed or request for page is performed. If it takes some time to retrieve page from disk or to do database operations the web server will have to wait causing blocking on input/output operation called as blocking I/O. For scaling such applications additional server copies has to be added.
To resolve the problem of blocking I/O, Node.js uses an event-driven model where the web server accepts the request, and then goes on to service the next web request. When the original request is completed, it gets back in the processing queue and when it reaches the front of the queue the results are sent back (or whatever the next action is). This model provides efficiency and scalability because at any point of time web server is not idle. It always accepts requests as it is not waiting for any I/O operations.
Node framework is composed of following components.
V8 (Google) : Google’s superfast java script implementation.
Libev : Event loop library.
Libeio : Thread pool Library.
Evcom : stream socket library on top of libdev.
Udns : non-blocking DNS resolver.
Figure 3: Node Architecture
Programming Model In Node.Js
The functions which are called explicitly, determines flow of program. This function registers corresponding handler callbacks. The http. CreateServer function, which is a wrapper around a low-level efficient HTTP protocol implementation, is passed a function as the only argument. This function is invoked whenever data for a new request is ready to be read. In another environment, a naÃ¯ve implementation might ruin the effect of eventing by synchronously reading a file and sending it back.
Our academic experts are ready and waiting to assist with any writing project you may have. From simple essay plans, through to full dissertations, you can guarantee we have a service perfectly matched to your needs.View our services
Node’s Explosive Growth
Node is an emerging technology and has to become technological face for web services like Facebook and Twitter which are massively used by people across the geographies Unlike PHP or Ruby. It can be inferred from the figure obtained from github that Node in the beginning could not do very well. Both committers and number of commits to node took off making Node’s growth very unpredictable. Committers and commits to Node on github started rising in fall 2010.
Figure 4: Explosive growth of Node
Developers have just started conversations about node. The following graph illustrates Twitter conversations around node. This graph clearly shows that though there were few spikes around the node in 2010 the more consistent conversations are being done in 2011
Also when Github traffic is compared for Rails vs. node, Rails had 270,000 views over the past three months. Node has 325,000, and it’s only going upâ€¦ it’s exploding.
Figure 4: Github hits for Node
There is definitely a bright future for Node for many reasons. Today everybody wants to create powerful applications like Facebook, Google instant search which are supporting millions of real time users on different devices ranging from laptop to mobiles. The applications certainly demands scalability and efficiency. If traditional frameworks used for developing such applications it would take lot of time also cost of hardware would be high. The Node provides scalable and fast model for development.
Node for real time voice
Product Voxer is going to make audio sexy again. This is like walkie-talkie and provides group IM.
Voxer has used basic principle of walkie-talkie and they have improved the use case lot. When user hits the button and begins talking Voxer sends message immediately to app user on other end. It provides two way communications. Both app users can receive chat requests through notifications so it’s up to users whether or not to join chat. Voxer also provides facility where users can re-listen messages in case they have missed any part of communication. It also facilitates group chat.
“Basic requirement of Voxer is to keep voice live. Node is the best choice for Voxer since Node allows maintaining large number of connections by keeping very low latency”, says Igal Perelman who is the VP of product Voxer. Developing application with node was third iteration of development in first iteration they tried developing Voxer with C++ for performance reason but it was too complicated to develop. Next they tried with Python but Pythons virtual machine was very slow. In third version they tried using Node. Node provides best of two worlds since it provides higher level language Java script for development and at the same time provides high performance virtual machine as it is developed on the top of Google’s V8 Java Script engine.
Node for developing Games
“Node Knockout” hackathon winner built multiplayer version of scrabble and made company out of the project in one year. On the other hand “Rails Rumble”[Ruby-on-Rails-flavored hackathon] is being conducted for four to five years but has only one company out of it.
There is no other technology which is as good as Node when it comes to developing real time applications. All the other technologies works in older framework whereas Node is designed keeping in mind real time systems so other technologies will take a long time to do same things.
Node for Collaboration
Mokingbird is tool for building wireframes rapidly. Mokingbird is being developed in Node.js and started making money. It is collaborative drawing tool and at the same time provides real time communication between clients and designers. Mockingbird was developed in very less span. They first tried developing Twisted and Tornado but node was the easiest way
Node.js is really an exciting technology which allows creating high performance real time systems easily. Since Node.Js uses java script it can be used it is very easy to use. By finding its benefits, and can used in many applications. Node.Js also supports many third party modules available for everything – including database connection layers, templating engines, mail clients, and even entire frameworks connecting all of these things together.
Cite This Work
To export a reference to this article please select a referencing stye below:
Related ServicesView all
DMCA / Removal Request
If you are the original writer of this essay and no longer wish to have your work published on UKEssays.com then please: