Tag-Archive for ◊ Performance ◊

Author:
Friday, March 02nd, 2012

Often while writing an application or adding a module to an existing application we wonder if we should go with multithreading. Multithreading can be a powerful tool, but only if used the right way. Lets examine.

There are two main reasons when one should consider multithreading,

  1. We have a GUI application and want to improve the user experience.
  2. We have a batch job processing application and want to improve the performance.

Lets take the first situation. I have developed a desktop application which splits large files into smaller chunks. I choose a movie file and want to split this into smaller chunks. Depending on the size of the file this operation may take anywhere from few seconds to few minutes. Lets say in the middle of the operation, I realize I chose the wrong file. If my application is single threaded I cant do anything to stop this as the main thread is working away splitting the file. So, if my application uses one thread, I can do only one thing at a time.

Now it makes sense to have this application multithreaded. You can start the file splitting on one thread while you have the main thread listening to user inputs. The thread doing the splitting work can be interrupted in case the user cancels the operation or needs to do something else.

So, writing GUI applications with multithreading makes a lot of sense and almost all modern day applications are multithreaded.

Now lets take the second scenario. We have a batch processing job to do. We have a bunch of xml files which we have to parse and persist in a database. If I do this operation in my main thread, I would have to parse each xml file and put the data in database sequentially. If I want to speed this process up, the logical thing to do would be to process these files and update the database in parallel. But its not that simple, there is a catch.

One CPU can process only one thread at a given time. There is also an overhead involved in thread scheduling as time slicing will be done to give CPU time to different threads. So if 50 threads are started to process 100 files, the job will definitely slowdown on a single CPU machine. At the same time doing the process in one thread does not make sense as the process involves i/o and db operations which are time consuming. A thread waiting on i/o is automatically removed and another thread is given a chance by most operating systems today. So the ideal number here would be around 5 threads. In case the environment has more than one CPU, the number of threads can be increased. This can even be decided at run time. The number of CPUs available for the VM can be got from the Java API Runtime.getRuntime().availableProcessors(). This can be multiplied with a suitable factor to get the number of threads required to process the job.

Multithreading for batch jobs should be considered based on the platform on which the process runs. Even better would be to have this configurable at run time.

It is good to consider the above while developing multithreaded GUI or batch jobs. In case we didn’t get the required performance, we now know where we were going wrong.

Author:
Tuesday, February 02nd, 2010

3rd party components are a boon in today’s development environment- the can reduce considerable development costs, but they pose a considerable risk to the overall project if some important factors are not taken into account. I will like to put some of such steps which a developer/development team should ensure before making a choice of such component. These practices have become a part of our working at iSense India

- Performance of 3rd party components – It is always a good practice to try out a new 3rd party component by doing a spike/proof of concept before actually working on a concrete user story which would use these component. Usually developers do this spike in the development environment and make conclusions over the performance. The catch is that software code performance varies on different inputs and environments. To make a decision on using the component, a good idea is to test the 3rd party component with production or production alike environment. Components which would perform in the range of milliseconds in a development environment (with non-real and small data) will may become unusable/perform poorly when tested in production alike environments.
We at iSense India have a rule corresponding to this and can be helpful to others – Before making a decision to use a 3rd party component, always performance test the 3rd party components on a production alike test environment to avoid last minute surprises.
- Deployment issues with the 3rd party components – 3rd party components are built and field-tested for specific platforms and by external users. There is a good chance what works on one machine does not work on another. In case the production environment is not well defined before the start of the project, teams can make wrong choices on choosing such a component.
So in short: Always ensure that you have verified or know that the software you are developing will work on the final production environment
- Support : Most of the times there are options in choosing a control – Commercial/Open Source. Usually when you buy the commercial option choose the one which comes with the source and binaries. This would ensure that even in the future you can change or adapt the code to your needs. In case of commercial software you would also like to check what level of support the vendor can provide and if they have an active forum list. With Open source solutions this is not a problem as the source is always available. Also it’s a good idea to check the bugs/issues related to one’s required functionality
- Code Quality – At iSense we ensure that all code developed passes code metrics and analysis parameters. Usually, the codes in these 3rd party components do not score high on code quality metrics and practices and this can affect your complete application code quality.

- Additional training – Sometimes using a 3rd party component takes more time than developing it yourself, this happens when either the 3rd party control is a complex application, or one which has no documentation/information available and hence becomes complex to understand and execute within a set time. In such cases it’s better to put some effort and getting an available training from a fellow organization member/commercial vendor or partner who has experience with the tool. This training can save a considerable time while executing the project. This should also be factored in estimating the time to develop the software project.
After all nobody wants to re-invent the wheel, using 3rd party components can help you reduce the time ,effort and the cost but be careful with the fine prints when choosing one.

Author:
Monday, December 14th, 2009

What’s Symfony?
Symfony is a web application MVC framework for PHP projects. It aims to speed up the creation and maintenance of web applications, and to replace the repetitive coding tasks.

Why use an MVC framework?

  • Avoid €œreinventing the wheel€
  • Use proven, tested code
  • Speed up application development
  • Easy to maintain
  • Code cleanliness
  • Structured the code

Why Symfony?

  • Supports complex web applications
  • Idea adopted from existing framework (Mojavi, Prado, rails, Django)
  • Clean MVC Seperation
  • Configurability, Flexibility
  • Write less code
  • Support Unit testing and functional testing

Database Support

  • Mysql, PostgreSQL, Oracle
  • Object Role Modeling (ORM)
  • Propel as default
  • It doesn’t require extrenal ORM

The Symfony supports most of the databases and the beauty of framework is that we can change the database at any stage of development. Since the database is different layer it won’t affect the other layer of the code.

Speed & Performance

  • Cache configuration
  • Caching on page, function , query
  • Disable / enable plugins, databases, modules

Other Features

  • Easy to Manage Template
  • SEO Friendly link/ url
  • Friendly logging
  • Assessment on loading time

Plugins and helper

  • Ajax enabled plugins
  • jQuery, dojo, extjs, yui
  • Create your own plugin and reuse
  • Autocomplete
  • Drag and drop
Famous Applications
Yahoo! answer
Yahoo! bookmark
delcious
Daily Motion
etc…

Famous Applications using Symfony Framework

Yahoo! answer

Yahoo! bookmark

delcious

Daily Motion

etc…