[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


C++ Application Architecture

Posted on 2004-08-05
Medium Priority
Last Modified: 2010-04-21

I'm not sure if I'm posting in the right channel, so apologies if this is the wrong one.

We currently have a quite large application written in C that is a collection of cgi programs that are called through an Apache server via XML.  A client makes a requests on our cgi's, the cgi's perform an operation and then return the result to the client (again in XML).  The C application is a back-end of a web site and has many uses.  We roughly serve about 2,000,000 number of client requests per day, some of the requests are quite resourceful and can take upto 40 seconds to respond to the client.  The C application has many external communication channels that it must communicate with over XML and also has MySQL databases for lookup/storage.

The time has come to re-write the application due to pressure from outside sources not happy about the scalability and that it is using cgi's and no database pooling.

The application will be re-written using C++ and I'm looking at what ways it can be done.  The objective it to make it more scalable and make a persistent framework where each client request is handled by a threaded server so reducing overhead of running a new process.

So far I have come up with the idea that I can write a threaded server using pthreads that will listen on a port, accept new clients and create a new thread to handle that process.  this is obviously a very simple overview of what I want to do but I'd like to know if there is anything else I should like at ?

Our current platform is Redhat Linux, we have 9 application servers, on each server an apache instance runs one any of the cgi's can be called.

Any ideas / suggestions would be very helpful.



Question by:checkin
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 45

Expert Comment

ID: 11724598
Hi Marvin,

C++ is data-centric and C is procedure centric ... Here what you have listed is all procedures. This and my natural affinity for C compels me to recommend optimizing the existing code rather than rewriting it. Rewriting is rarely a sucees story.

That out of the way, yes the ideas you are having are in the right direction ... That very well might be the way to go. There will be some design issues you might need to consider,e.g. max threads at any time, max free threads at any time, min number of threads you would like to pre-spawn so that they are ready to serve when a request arrives, design of a thread manager etc.

Along with that I am sure you will be having some project specific nuances which I am not aware of, but am sure that they are there ;o)

Apache web server is built on similar architecture. A glance through apache documentation should be able to provide some insight.


Author Comment

ID: 11724656
Ok, thanks for the information.

I agree that a re-write is probably not going to give much benefit, unfortunately the company that we work in does not see that.  The whole company is Java/J2E based and see that our application written in C is a legacy application.  The application is maintained by only 3 people and these people (me being one of them) only have the knowledge of how it does and should work.
The problem we have right now about making it persistence is that over the years of evolution the memory management has been ignored due to processes starting and ending, people got lazy abouting freeing it.  It would take just as long to go through each function and make it release its memory.  Additionally one of the cgi's which is threaded itself is known to do the odd core dump which would be fatal for a persitant server process (I'm sure thats down to a concurrency issue though).

Anyway thanks again for the information, I'll try and find some information on creating a thread manager.

LVL 45

Accepted Solution

sunnycoder earned 2000 total points
ID: 11724910
Hi Marvin,

Does your company believe that a rewrite will be bug free? Searching malloc will be easy ... all you need is a grep ... If normal coding procedures have been followed then the functions that mallocs memory should be responsible for freeing it. ... But I feel that pursuing this point has little utility as this decision seems to involve the higher ups.

Thread manager would be custom to your application. You need to figure out the classes and data first (if you are going C++ way) and the interface that each class provides. Thread manager would be realtively simple part which will keep track of all the threads ... the free pool, the busy pool, max threads, min threads etc... How to request a thread for processing a request, how to free a thread and other such isssues might need some thought and might influence the performance and scalability to a certain extent.

Good luck

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question