blob: 0b96c9b91145942fa4aa2636621c86ac3c5ec5b9 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<title>1.2 - Why MINA &mdash; Apache MINA</title>
<link href="/assets/css/common.css" rel="stylesheet" type="text/css"/>
<link href="/assets/css/mina.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<script src="https://www.apachecon.com/event-images/snippet.js"></script>
<div id="container">
<div id="header">
<div id="subProjectsNavBar">
<a href="/">
Apache MINA Project
</a>
&nbsp;|&nbsp;
<a href="/mina-project/">
<strong>MINA</strong>
</a>
&nbsp;|&nbsp;
<a href="/asyncweb-project/">
AsyncWeb
</a>
&nbsp;|&nbsp;
<a href="/ftpserver-project/">
FtpServer
</a>
&nbsp;|&nbsp;
<a href="/sshd-project/">
SSHD
</a>
&nbsp;|&nbsp;
<a href="/vysper-project/">
Vysper
</a>
</div>
</div>
<div id="content">
<div id="leftColumn">
<div id="navigation">
<a class="acevent" data-format="wide" data-width="170"></a>
<h5>Social Networks</h5>
<ul>
<li><a href="https://fosstodon.org/@apachemina">Apache MINA Mastodon</a></li>
</ul>
<h5>Latest Downloads</h5>
<ul>
<li><a href="/mina-project/downloads_2_0.html">Mina 2.0.25</a></li>
<li><a href="/mina-project/downloads_2_1.html">Mina 2.1.8</a></li>
<li><a href="/mina-project/downloads_2_2.html">Mina 2.2.3</a></li>
<li><a href="/mina-project/downloads_old.html">Mina old versions</a></li>
</ul>
<h5>Documentation</h5>
<ul>
<li><a href="/mina-project/documentation.html" class="external-link" rel="nofollow">Base documentation</a></li>
<li><a href="/mina-project/userguide/user-guide-toc.html" class="external-link" rel="nofollow">User guide</a></li>
<li><a href="/mina-project/2.2-vs-2.1.html" class="external-link" rel="nofollow">2.2 vs 2.1</a></li>
<li><a href="/mina-project/2.1-vs-2.0.html" class="external-link" rel="nofollow">2.1 vs 2.0</a></li>
<li><a href="/mina-project/features.html" class="external-link" rel="nofollow">Features</a></li>
<li><a href="/mina-project/road-map.html" class="external-link" rel="nofollow">Road Map</a></li>
<li><a href="/mina-project/quick-start-guide.html" class="external-link" rel="nofollow">Quick Start Guide</a></li>
<li><a href="/mina-project/faq.html" class="external-link" rel="nofollow">FAQ</a></li>
</ul>
<h5>Resources</h5>
<ul>
<li><a href="/mina-project/mailing-lists.html" class="external-link" rel="nofollow">Mailing lists &amp; IRC</a></li>
<li><a href="/mina-project/issue-tracking.html" class="external-link" rel="nofollow">Issue tracking</a></li>
<li><a href="/mina-project/sources.html" class="external-link" rel="nofollow">Sources</a></li>
<li><a href="/mina-project/gen-docs/latest-2.0/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.0.25</a></li>
<li><a href="/mina-project/gen-docs/latest-2.1/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.1.8</a></li>
<li><a href="/mina-project/gen-docs/latest-2.2/apidocs/index.html" class="external-link" rel="nofollow">API Javadoc 2.2.3</a></li>
<li><a href="/mina-project/gen-docs/latest-2.0/xref/index.html" class="external-link" rel="nofollow">API xref 2.0.25</a></li>
<li><a href="/mina-project/gen-docs/latest-2.1/xref/index.html" class="external-link" rel="nofollow">API xref 2.1.8</a></li>
<li><a href="/mina-project/gen-docs/latest-2.2/xref/index.html" class="external-link" rel="nofollow">API xref 2.2.3</a></li>
<li><a href="/mina-project/performances.html" class="external-link" rel="nofollow">Performances</a></li>
<li><a href="/mina-project/testimonials.html" class="external-link" rel="nofollow">Testimonials</a></li>
<li><a href="/mina-project/conferences.html" class="external-link" rel="nofollow">Conferences</a></li>
<li><a href="/mina-project/developer-guide.html" class="external-link" rel="nofollow">Developers Guide</a></li>
<li><a href="/mina-project/related-projects.html" class="external-link" rel="nofollow">Related Projects</a></li>
<li><a href="https://people.apache.org/~vgritsenko/stats/projects/mina.html" class="external-link" rel="nofollow">Statistics</a></li>
</ul>
<h5>Community</h5>
<ul>
<li><a href="https://www.apache.org/foundation/contributing.html" class="external-link" rel="nofollow">Contributing</a></li>
<li><a href="/contributors.html" class="external-link" rel="nofollow">Team</a></li>
<li><a href="/special-thanks.html" class="external-link" rel="nofollow">Special Thanks</a></li>
<li><a href="https://www.apache.org/security/" class="external-link" rel="nofollow">Security</a></li>
</ul>
<h5>About Apache</h5>
<ul>
<li><a href="https://www.apache.org" class="external-link" rel="nofollow">Apache main site</a></li>
<li><a href="https://www.apache.org/licenses/" class="external-link" rel="nofollow">License</a></li>
<li><a href="https://www.apache.org/foundation/sponsorship.html" title="The ASF sponsorship program" class="external-link" rel="nofollow">Sponsorship program</a></li>
<li><a href="https://www.apache.org/foundation/thanks.html" class="external-link" rel="nofollow">Thanks</a></li>
</ul>
<h3><a name="Navigation-Upcoming"></a>Upcoming</h3>
<ul>
<li>No event</li>
</ul>
</div>
</div>
<div id="rightColumn">
<div class="nav">
<div class="nav_prev">
<a href="ch1.1-nio-overview.html">1.1 - NIO Overview</a>
</div>
<div class="nav_up">
<a href="ch1-getting-started.html">Chapter 1 - Getting Started</a>
</div>
<div class="nav_next">
<a href="ch1.3-features.html">1.3 - Features</a>
</div>
<div class="clearfix"></div>
</div>
<h1 id="why-mina">Why MINA?</h1>
<p>Writing network applications are generally seen as a burden and perceived as low level development. It is an area which is not frequently studied or known by developers, either because it has been studied in school a long time ago and everything has been forgotten, or because the complexity of the network layer is frequently hidden by higher level layers, so you never get deep into it.</p>
<p>Added to that (when it comes to asynchronous IO) an extra layer of complexity comes into play: time.</p>
<p>The big difference between <strong>BIO</strong> (Blocking IO) and <strong>NIO</strong> (Non-Blocking IO) is that in <strong>BIO</strong>, you send a request, and you wait until you get the response. On the server side, it means one thread will be associated with any incoming connection, so you won&rsquo;t have to deal with the complexity of multiplexing the connections. In <strong>NIO</strong>, on the other hand, you have to deal with the synchronous nature of a non-blocking system, which means that your application will be invoked when some events occur. In <strong>NIO</strong>, you don&rsquo;t call and wait for a result, you send a command and you are informed when the result is ready.</p>
<h2 id="the-need-of-a-framework">The need of a framework</h2>
<p>Considering those differences, and the fact that most of the applications are usually expecting a blocking mode when invoking the network layer, the best solution is to hide this aspect by writing a framework that mimics a blocking mode. This is what <strong>MINA</strong> does!</p>
<p>But <strong>MINA</strong> does more. It provides a common IO vision to an application that needs to communicate over <strong>TCP</strong>, <strong>UDP</strong> or whatever mechanism. If we consider only <strong>TCP</strong> and <strong>UDP</strong>, one is a connected protocol (<strong>TCP</strong>) where the other is connectionless (<strong>UDP</strong>). <strong>MINA</strong> masks this difference, and makes you focus on the two parts that are important for your application: the application code and the application protocol encoding/decoding.</p>
<p>*<strong>MINA</strong> does not only handle <strong>TCP</strong> and <strong>UDP</strong>, it also offers a layer on top of serial communication (<strong>RSC232</strong>), over <strong>VmpPipe</strong> or <strong>APR</strong>.</p>
<p>Last but not least, <strong>MINA</strong> is a network framework that has been specifically designed to work on both the client side and server side. Writing a server makes it critical to have a scalable system, which is tunable to fit the server needs, in terms of performance and memory usage. This is what <strong>MINA</strong> is good for, making it easy to develop you server.</p>
<h2 id="when-to-use-mina">When to use MINA?</h2>
<p>This is an interesting question! <strong>MINA</strong> does not expect to be the best possible choice in all cases. There are a few elements to take into account when considering using <strong>MINA</strong>. Let&rsquo;s list them:</p>
<ul>
<li>
<p>Ease of use
When you have no special performance requirements, <strong>MINA</strong> is probably a good choice as it allows you to develop a server or a client easily, without having to deal with the various parameters and use cases to handle when writing the same application on top of <strong>BIO</strong> or <strong>NIO</strong>. You could probably write your server with only a few lines of code, and there are less pitfalls in which you are likely to fall.</p>
</li>
<li>
<p>A high number of connected users
<strong>BIO</strong> is definitively faster that <strong>NIO</strong>. The difference is something like 30% in favor of <strong>BIO</strong>. This is true for up to a few thousands of connected users, but up to a point, the <strong>BIO</strong> approach just stops scaling; you won&rsquo;t be able to handle millions of connected users using one thread per user! <strong>NIO</strong> can. Now, one other aspect is that the time spent in the <strong>MINA</strong> part of your code is probably non significant, compared to whatever your application will consume. At some point, it&rsquo;s probably not worthwhile to spend the energy trying to writing a faster network layer on your own for a gain which will be barely noticeable.</p>
</li>
<li>
<p>A proven system
<strong>MINA</strong> is used by many applications all over the world. There are some <em>Apache</em> projects based on <strong>MINA</strong>, and they are working pretty well. This gives you the ease of mind that you won&rsquo;t have to spend hours on some cryptic errors in your own implementation of the network layer.</p>
</li>
<li>
<p>Existing supported protocols
<strong>MINA</strong> ships with various implemented protocols: HTTP, XML, TCP, LDAP, DHCP, NTP, DNS, XMPP, SSH, FTP&hellip; At some point, <strong>MINA</strong> can be seen not only as a <strong>NIO</strong> framework, but as a network layer with some protocol implementation. In the near future <strong>MINA</strong> may offer a more extensive collection of protocols for you to use.</p>
</li>
</ul>
<div class="nav">
<div class="nav_prev">
<a href="ch1.1-nio-overview.html">1.1 - NIO Overview</a>
</div>
<div class="nav_up">
<a href="ch1-getting-started.html">Chapter 1 - Getting Started</a>
</div>
<div class="nav_next">
<a href="ch1.3-features.html">1.3 - Features</a>
</div>
<div class="clearfix"></div>
</div>
</div>
<div id="endContent"></div>
</div>
<div id="footer">
&copy; 2003-2024, <a href="https://www.apache.org">The Apache Software Foundation</a> - <a href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy Policy</a><br />
Apache MINA, MINA, Apache Vysper, Vysper, Apache SSHd, SSHd, Apache FtpServer, FtpServer, Apache AsyncWeb, AsyncWeb,
Apache, the Apache feather logo, and the Apache Mina project logos are trademarks of The Apache Software Foundation.
</div>
</div>
</body>
</html>