Solved

C++ Application Architecture

Posted on 2004-08-05
3
381 Views
Last Modified: 2010-04-21
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.

0
Comment
Question by:checkin
  • 2
3 Comments
 
LVL 45

Expert Comment

by:sunnycoder
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.

cheers
sunnycoder
0
 

Author Comment

by:checkin
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.

Marvin.
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 500 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
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now