3

I have a flight planning system in .NET/SQL Server which needs to perform several validation checks. This needs to work on both a windows and a web client. Currently the checks run synchronously but this is slowing the system down, plus it is often repeating the same checks. Like "is this aircraft in the right start location", "is the aircraft available" and many more complicated checks. This is needed since the current system does not know if other flights have been changed which might cause issues.

Am looking for a way in which I could create a single background process which runs independently and asynchronously on an interval and might be triggered by data changes or explicit requests. This process could then update a list of found issues per flight. Another process could simply use this list to report the issues to the user without having to perform the checks itself.

Any ideas on architecture pattern and best practices to implement something like this? Would like to keep the installation process fairly simple, so the fewer "moving parts" the better.

  • When you say "Currently the checks run synchronously but this is slowing the system down, plus it is often repeating the same checks." do you mean you have a check list and your system goes through it in a 1 by 1 order? or an event happens in the system and initiates this check list? (So if you had two identical events it will perform the check list twice?) – Roman Mik Jul 22 '14 at 16:28
  • We currently have a list of checks which indeed gets completely repeated when things change. There is no system that decides which part of the checklist need to be redone and which not. For example changing fuel uptake in one place changes weights and endurance for all consecutive landings plus the fuel reserves and needs to be checked against tank capacity. Hence we opted for one list of checks rather than a if this changed check that etc. Interesting point though! – Theo de Roo Jul 23 '14 at 20:33
3

One method that I used in a somewhat similar position that allowed me to force integrity on the data while ensuring a speedy experience for my users was to asynchronously build the request on the server side.

So, if feature A (.75 seconds to process calculations), B (2 seconds), and C (3 seconds) were all part of a single page and when I posted this page the processing time for A + B + C was just too great. 5.75 seconds isn't horrible, but people start noticing speed at this point. My page processing actually took about 10 seconds because of everything that needed to be done. To fix this I split them into separate functions on the same page.

When you added A (let's say aircraft position that does 20 different calculations on things and took .75 seconds), it was asynchronous. I had a server side function that did the processing for this, including checks, file movement, etc. The information for A was stored on the server as part of a partial request (I used REDIS to keep this information).

When you add your B information, the processing again happens asyncronously.

And C.

So, when you finally hit "Submit", you don't have to do all that processing again. It's been already done and the results / information / verification are on the server waiting as a partial submission. Your actual submission would kick of a process that basically says "take the partial information on the server and combine it into x (x being a record, request, or whatever you finally do with it)".

I realize I'm being high-level. I can try to provide a code sample if you want. But, my 10 seconds synchronous process of a page (ain't nobody have time for that), turned into multiple submissions for the page. People don't mind waiting 1 second after they update each part of the page. When they actually post the page, all the work has been done in the background, so the response time is about 1 second. They think it's really quick, but it's only because all the work was already done.

One note, the purpose for storing the information on the server side helps prevent security issues. If you only "check" A when they complete it on the page and send back an, "It's all good," message, but then on submission, take the value of A from the submission information assuming it's the same information that you checked, you could open yourself up to malicious data. I receive the partial information, store it server side, and on post, use that information so I know with 100% certainty that the information I'm using is what has already passed all my checks.

Hope that helps!

  • I receive the partial information, store it server side, and on post, use that information so I know with 100% certainty that the information I'm using is what has already passed all my checks. An alternative is to send back an encrypted hash of the result to the client along with the result. On submission, the client sends back the results and encrypted hashes. The server can now decrypt the hash and compare it to the hash of what the client just sent. If the client tampers with the data the hash won't line up. – Doval Jul 23 '14 at 17:12
  • @Doval you basically described sessions :) – Florian Margaine Jul 23 '14 at 18:55
  • Your solution seems to focus more on (expensive) user input validation while I'm needing to solve broader problem than that. For example two valid flights can be entered but by changing aircraft for one a later (unchanged) flight can suddenly be invalid. So unless I have a system that performs checks across multiple flights and days on a regular interval I do not see how I could get this to work. Also I'm looking at what tooling to use, so like would it make sense to write these checks as a SQL CLR stored procedure? – Theo de Roo Jul 24 '14 at 8:39
  • My solution offered a method of breaking up multiple calculations based on various input into chunks. Your problem-space is not well defined in this question. You mentioned you have several checks you do synchronously, causing it to be slow. That was all the information given, the simplest answer was to break things out asynchronously. Perhaps if your question were made clearer as to whether this system already exists or you are looking for architectural help as well as specifically at what state you have a bottleneck, any answers you receive would be clearer as well. – iolympian Jul 30 '14 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.