Link to home
Start Free TrialLog in
Avatar of checkin
checkin

asked on

C++ Application Architecture

Hi,

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.

Regards,

Marvin.

Avatar of sunnycoder
sunnycoder
Flag of India image

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.

cheers
sunnycoder
Avatar of checkin
checkin

ASKER

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.

Marvin.
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial