Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

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.

0
checkin
Asked:
checkin
  • 2
1 Solution
 
sunnycoderCommented:
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
 
checkinAuthor Commented:
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
 
sunnycoderCommented:
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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now