Cheap Web Hosting for Developers

PHP, MySQL, Java, Unix Cheap Web Hosting

108 Chapter 3 Application Design: A Real-Life Example

Filed under: Web Applications Development With PHP4.0 — webmaster @ 06:09

108 Chapter 3 Application Design: A Real-Life Example What are the reasons? Try to find and write them down.Try to find the critical points this is crucial when having to optimize later on. A chain is only as strong as its weakest link, and software is only as fast as its slowest inner loop.The process of finding these bottlenecks is called profiling and is extremely important. When using a database, the bottleneck is the database: the time required to invoke the database, let it execute the (relatively small) query, retrieve the result, and determine what to do next (called the overhead) is pretty long compared to the result we re getting. In other words, we re using a huge software system designed for complex data storage to exchange simple, Boolean values if there s something a database was not designed for, it s this. No wonder it didn t perform optimally; the bottleneck is the overhead, the time required for setup and deinitialization. The file system performed badly because it was not designed for this usage, and because of other limitations: PHP doesn t include optimal file-system access methods. Determining the existence of a file requires constant cache invalidations and recaching again, large overhead for a trivial task. So why not use something completely different? We re surely not the first people having to deal with interprocess communication; others must have come up with good solutions for this already.And so we reach the next possibility:semaphores. Semaphores do exactly what we want to do:They work as signals.Semaphores are counters stored in shared memory.You can acquire a semaphore and thus increase its counter,and you can release a semaphore,decreasing its counter.Additionally,there s the possibility of waiting for a semaphore to become free, meaning that its counter falls back to zero.This option has one drawback,however:Semaphores were meant to lock resources, to create some kind of scheduling mechanism allowing many processes to wait for available time on a device,or something similar.Whenever you re waiting for a semaphore to become free, the process that s waiting is put to sleep and cannot perform other tasks. If the main process was waiting for the user-input field to signal a new message, it would sleep and couldn t process the incoming network traffic. No reason to give up yet; people have come up with still other solutions. Setting Flags in Shared Memory Shared memory is similar to semaphores, but a bit more versatile; shared memory is memory that s available to every process in a system. Multitasking systems are usually designed in such a way that each process is running completely isolated from other processes for security reasons. Different processes can share data by setting up and connecting to special memory blocks, namely shared memory blocks.These blocks can then contain variables (or any other kind of data, but PHP only supports storage of concrete variables).

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

10 Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Cheap Web Hosting