DRAFT IN PROGRESS |
|
PLEASE DON'T EDIT UNLESS YOU ASKED FOR. |
|
Locked by: Artyom |
|
## Introduction |
|
CppCMS is a web development framework for performance |
demanding applications. It enables improvement of over |
an order of magnitude in performance, hardware real |
estate requirements and power consumption for a typical |
industrial web site. |
|
CppCMS design goal was to reduce costs for web site |
maintenance, help develop highly scalable systems and |
preserve the environment. |
|
With the traditional web development technology, hosting |
most demanding web applications requires large server |
farms consuming lots of electricity. Developing web |
services that can run in parallel on a large server |
cloud presents a software engineering challenge. |
All of these may be avoided with CppCMS, which often |
enables hosting a web service on a single server |
when otherwise a large array of servers would be required. |
|
On the other side of the spectrum, CppCMS is also being |
used in embedded environments. This enables setting up |
a dedicated web interface on resource constrained |
low-power embedded CPU. Today, a growing number |
of embedded devices use this kind of lightweight web |
services for control and configuration. Examples include |
networking components, industrial controllers, monitoring |
equipment and consumer electronics (e.g. for firmware updates). |
|
CppCMS was tested on a variety of platforms, including Linux, |
Windows, Solaris, FreeBSD, Mac OS X and several embedded |
platforms. It is compatible with all industry-leading |
web servers (Apache, IIS, Nginx, etc) and also provides |
a built-in lightweight web server which can be used instead. |
|
CppCMS is free open source software. It may be distributed |
under LGPL license. For commercial applications, it offers |
an alternative commercial license. |
|
You can learn more from our website: <http://cppcms.com> |
|
|
## Case Study |
|
Let's take a look on a simple web application -- a blog |
implemented using several modern technologies: CppCMS, Java Servlets and PHP. |
This application has typical features that most |
applications of its kind have: database access, text formatting, comments sanitation and of course caching. |
We implemented a simple web application --- a blog |
using several modern technologies: CppCMS, |
Java Servlets and PHP. |
This application had typical features that most |
applications of its kind had: database access, text formatting, comments sanitation and of course |
caching. |
|
In order to perform the testing we created a typical |
workload. We requested multiple blog pages and ensured |
that some of the pages were taken from the web cache |
and some were fully generated simulating required |
cache hit-miss ratio. |
In order to perform the measurements, we created a typical |
workload. A special client requested different |
blog pages and ensured that some of them |
were taken from the web cache and some were |
fully generated simulating a required cache |
miss ratio. |
|
In this case study we used 20% cache miss ratio. |
This cache miss ratio is a typical for one of the |
larges web sites around the word: Wikipedia. |
For the given setup we had measued following parameters: |
In this case study, we used 20% cache miss ratio. |
This cache miss ratio value is a typical value |
for the one of the largest web sites: Wikipedia. |
|
We had measured following parameters: |
|
1. Speed: how many pages per second can be generated |
2. Resources: memory consumption |
1. Speed --- how many pages per second the application was able to generate. |
2. Resource consumption --- how much memory the application used. |
|
You can see the results at the figure [1](#hitspersec). |
At the left side you can see that the CppCMS based blog is faster |
then the Java Servlet and PHP based applications by an order of |
magnitude. |
The benchmark results are shown at the figure [1](#hitspersec). You can see at the left |
side of the figure that the blog implemented using |
CppCMS technology is faster than the |
blog implemented using JSP or PHP by an order of magnitude. |
|
The memory consumption of the CppCMS based application was significantly |
lower as well. The application written in PHP consumed almost 3 times more |
memory and the Java Servlet based application consumed almost 30(!) times more |
memory then CppCMS. |
The memory consumption of the CppCMS based application was significantly lower as well. The application implemented |
using PHP consumed almost 3 times more memory. |
The application implemented using JSP |
technology consumed almost 30(!) times more memory |
than the application based on CppCMS. |
|
You can clearly see that CppCMS performs significantly better then other |
technologies in both performance and resource usage simultaneously. |
You can clearly see that the applications which uses CppCMS |
performs significantly better than ones implemented |
using PHP or JSP. |
It outperforms other technologies in speed and |
resource consumption simultaneously. |
|
<span id="hitspersec">Figure 1: Typical Application Performance<br/> ![Typical Application Performance](/files/wp/20per.png) ![Typical Application Performance](/files/wp/memory.png)</span> |
|
|
|
## Technology |
|
CppCMS incorporates many unique approaches to achieve its goals. |
|
CppCMS uses C++ as the primary programming language for the |
web development. |
It allows to create highly modular object-oriented |
designs and on the other hand it allows performing |
very fine and low level optimization at critical |
points to improve the overall performance or reduce the resource |
consumption. |
|
Performance is the core part of the CppCMS design. For instance, |
unlike the most web frameworks' caching systems that use simple key--value model, |
CppCMS adds an additional level to the caching --- triggers |
(see fig. [2](#keys).) This approach allows keeping the web cache |
highly consistent, and on the other hand, it preservers |
cached objects for longer time reducing the loads on the |
web application. The cached web pages are |
stored already compressed automatically reducing both network latency |
and the CPU load. |
|
<span id="keys"> |
Figure 2: CppCMS features trigger based cache invalidation system that allows |
to invalidate many cached objects at once<br/> |
![Fig 2](/files/wp/keys.png) |
</span> |
|
|
The scalability is the other major concern in this web framework design. |
For example: CppCMS provides client-side session storage based on encrypted |
and digitally signed cookies as lineally scalable storage; the cache |
system uses two level cache in order to reduce the network loads |
and cache-server's response times, see fig. [3](#l2) |
|
|
<span id="l2">Figure 3: CppCMS distributed cache system uses two level cache that reduces |
the network load and the latency for the accessing the |
most frequently used objects<br/>![Fig 3](/files/wp/l2.png) |
</span> |
|
|
Despite all the performance concerns, CppCMS allows to develop safe |
and secure web application by providing a set of built-in tools |
that makes secure web design easier: forms validation |
with built-in Cross-Site Request Forgery (CSRF) protection, |
input character set validation, fast and efficient |
Cross-Site Scripting (XSS) filtering, SQL-injection |
prevention tools, built-in support of file-system level isolation |
using `chroot()` and more. |
|
## Ajax and Comet |
|
Modern web applications are highly interactive. |
The client side and the server side interchange |
the data all the time. CppCMS fully supports |
this kind of web development. |
|
CppCMS recommends and uses JSON as |
a lightweight and powerful client--server data interchange format. |
CppCMS provides a built-in tools for |
straight forward conversion between the JSON and |
the C++ objects. It implements the JSON-RPC protocol |
giving easy to use tools for interaction |
between the client side and the server side --- the Ajax support. |
|
Unlike most web development frameworks, |
CppCMS technology supports both client side |
and the server side events --- the Comet support. |
|
CppCMS allows to create both synchronous and asynchronous |
web applications on the server side using the same approach. |
This approach allows tight integration between different |
types of applications: synchronous that respond to the |
client's requests and asynchronous that |
respond to server side events and notify the client |
about them, see fig. [4](#comet) |
|
<span id="comet" >Figure 4: CppCMS provides built-in support for Comet technology |
and allows to handle both synchronous and asynchronous |
requests with very low resource usage<br/> |
![Fig 4](/files/wp/eventloop.png)</span> |
|
|
This unique approach allows the CppCMS based application to handle hundreds and |
thousands simultaneous connections with very low resource consumption. |
|
## Key Features |
|
1. High performance |
2. Low resource consumption |
3. Model-View-Controller application design pattern |
4. Advanced web template system that is directly compiled to the native code |
4. Powerful cache system |
5. Scalable web session storage |
1. Multiple security protection features like: XSS filters, SQL-injection and CSRF protection tools. |
1. Web server interoperability using industry standard protocols: FastCGI, SCGI and HTTP. |
1. Built-in web server for embedded applications |
1. Ajax integration using JSON and JSON-RPC |
1. Native Comet integration and support --- server side events support |
1. Powerful internationalization and localization support\footnote{CppCMS contributed |
localization library to the Boost project: Boost.Locale}. |
1. Efficient database connectivity with built-in connection |
pooling and transparent prepared statement caching |
|