Advance Programming Week 7-8
Advance Programming Week 7-8
is hardware or software that is used to store something, usually data, temporarily in a computing environment. It is a small amount of faster, more expensive memory used to improve the
performance of recently or frequently accessed data. Cached data is stored temporarily in an accessible storage media that's local to the cache client and separate from the main storage.
Cache is commonly used by the central processing unit (CPU), applications, web browsers and operating systems. Cache is used because bulk or main storage can't keep up with the demands
of clients. Cache decreases data access times, reduces latency and improves input/output (I/O). Because almost all application workloads depend on I/O operations, the caching process
improves application performance
When a cache client attempts to access data, it first checks the cache. If the data is found there, that is referred to as a cache hit. The percent of attempts that result in a cache hit is called the
cache hit rate or ratio. Requested data that isn't found in the cache -- referred to as a cache miss -- is pulled from main memory and copied into the cache. How this is done, and what data is
ejected from the cache to make room for the new data, depends on the caching algorithm, cache protocols and system policies being used.
Web browsers like Safari, Firefox and Chrome use browser caching to improve the performance of frequently accessed webpages. When a user visits a webpage, the requested files are stored
in a cache for that browser in the user's computing storage.
To retrieve a previously accessed page, the browser gets most of the files it needs from the cache rather than having them resent from the web server. This approach is called read cache. The
browser can read data from the browser cache faster than it can reread the files from the webpage
• It diverts I/O to cache, reducing I/O operations to external storage and lower levels of storage area network
Cache memory is either included on the CPU or embedded in a chip on the system board. In newer machines, the only way to increase cache memory is to upgrade the system board and CPU
to the newest generation. Older system boards may have empty slots that can be used to increase the cache memory.
How are caches used? Caches are used to store temporary files, using hardware and software components. An example of a hardware cache is a CPU cache. This is a small chunk of memory
on the computer's processor used to store basic computer instructions that were recently used or are frequently used.
Web browsers are a good example of application caching. As mentioned earlier, browsers have their own cache that store information from previous browsing sessions for use in future
sessions. A user wanting to a re watch YouTube video can load it faster because the browser accesses it from cache where it was saved from the previous session.
• operating systems, where commonly used instructions and files are stored;
• domain name systems, where they can be used to store information used to convert domain names to Internet Protocol addresses; and
• Offline work. Caches also let applications function without an internet connection
• Performance. Caches are generally small stores of temporary memory. If they get too large, they can cause performance to degrade.
• Outdated information.
Cache algorithms
Instructions for cache maintenance are provided by cache algorithms. Some examples of cache algorithms include the following:
• Least Frequently Used keeps track of how often a cache entry is accessed. The item that has the lowest count gets removed first.
• Least Recently Used puts recently accessed items near the top of the cache. When the cache reaches its limit, the least recently accessed items are removed.
• Most Recently Used removes the most recently accessed items first. This approach is best when older items are more likely to be used.
Cache policies
Various caching policies determine how the cache operates. Then include the following:
• Write-around cache writes operations to storage, skipping the cache. This prevents the cache from being flooded when there are large amounts of write I/O. The disadvantage to this
approach is that data isn't cached unless it's read from storage. As a result, the read operation is slower because the data hasn't been cached.
• Write-through cache writes data to cache and storage. The advantage of write-through cache is that newly written data is always cached, so it can be read quickly. A drawback is that write
operations aren't considered complete until the data is written to both the cache and primary storage. This can introduce latency into write operations.
• Write-back cache is like write-through in that all the write operations are directed to the cache. But with write-back cache, the write operation is considered complete after the data is
cached. Once that happens, the data is copied from the cache to storage
Clearing the cache frees memory space on a device. A browser cache uses memory to store files downloaded directly from the web. Clearing it can solve user issues, such as the following;
• A full cache memory can cause applications to crash or not load properly.
• Old caches can contain outdated information and files, causing webpages to not load or load incorrectly. Clearing them can get rid of outdated information.
• Browser caches also contain saved personal information, such as passwords. Clearing them can protect the user.
Browser caches are the ones most end users are familiar with. In most cases, they are cleared by going to a settings or preferences tab or menu item.
• Scroll to the "Privacy and security" section. • Select Clear browsing data. • Choose a time period from the drop-down menu or choose All time to delete the entire cache.
Types of caches
Caching is used for many purposes. The various cache methods include the following: Cache memory is RAM that a microprocessor can access faster than it can access regular RAM. It is often
tied directly to the CPU and is used to cache instructions that are accessed a lot. A RAM cache is faster than a disk-based one, but cache memory is faster than a RAM cache because it's close
to the CPU
• Cache server, sometimes called a proxy cache, is a dedicated network server or service. Cache servers save webpages or other internet content locally.
• CPU cache is a bit of memory placed on the CPU. This memory operates at the speed of the CPU rather than at the system bus speed and is much faster than RAM.
• Disk cache holds recently read data and, sometimes, adjacent data areas that are likely to be accessed soon. Some disk caches cache data based on how frequently it's read. Frequently read
storage blocks are referred to as hot blocks and are automatically sent to the cache.
External Performance Tuning involves optimizing a system's performance by making adjustments to settings and configurations external to its core components, such as the operating system,
network, or hardware.
How it Works
Fine-tuning Communication: Optimizing the way different components of the system communicate
advantages: • Cost-Effective. • Quick Implementation. • Flexibility. Disadvantages • Limited Optimization. • Dependency on Environment. • Risk of Misconfiguration.
Data Component
Caching Data Component Caching is a technique used to store frequently accessed or computed data in a temporary storage area, known as a cache, to accelerate future access and reduce the
need to fetch the data from slower sources.
How it Works
• Data Component Caching: Storing product information, including images and prices, in a cache.
• Frequent Access: Products on the homepage or popular items are accessed frequently.
Advantages
• Improved Performance • Reduced Load on Resources • Enhanced User Experience • Data Consistency: • Storage Overhead • Complexity
Computational Reuse
Computational Reuse is a strategy in software development involves efficiently utilizing previously computed results or operations to avoid redundant calculations, thereby improving
performance and reducing computational overhead.
How it Works
• Identifying Repetitive Operations • Storing and Retrieving Results • Avoiding Redundant Calculations
Advantages:
• Performance Improvement: • Resource Efficiency • Enhanced Scalability • Complex Implementation • Storage Overhead • Data Consistency
Distributed application
Distributed applications (distributed apps) are applications or software that run on multiple computers within a network at the same time and can be stored on servers or cloud computing
platforms.
Unlike traditional applications that run on a single system, distributed applications run on multiple systems simultaneously.
They're also asynchronous -- meaning there's no synchronization between their internal clocks
can communicate with multiple servers or devices on the same network from any geographical location.
Distributed applications are broken up into two separate models -- the client software and the server software.
The client software or computer accesses the data from the server or cloud environment, while the server or cloud processes the data.
Distributed applications enable multiple users to access the apps at once. Many developers, IT professionals or enterprises choose to store distributed apps in the cloud because of its elasticity
and scalability, as well as its ability to handle large applications or workloads.
• web browsers;
Interacting with Databases
Interacting with databases refers to the process of accessing, manipulating, and managing data stored in a database.
How it Works:
• Connecting to the Database: The first step is establishing a connection between the application and the database. This is typically done using a database connection library or API.
• Executing SQL Queries: perform operations such as selecting data, inserting new records, updating existing records, or deleting records.
• Processing Results: displaying data to users, manipulating it, or using it for further processing
Advantages:
User Authentication: User authentication is the process of verifying the identity of a user, typically by requiring the user to provide valid credentials such as a username and password.
Session Security: Once a user is authenticated, a session is established to maintain the user's state across multiple requests. Session security is critical to protect user data and prevent
unauthorized access.
• Session Creation: • Session Storage • Session Tokens. • Session Expiry and Invalidation
Advantages:
Disadvantages:
Session Handling
is a crucial aspect of web development that involves managing user sessions to maintain state information between HTTP requests.
• Session Initiation • Data Storage • Session Tracking • Expiration and Invalidation • Session Security Measures:
Use Case Examples: • E-commerce Shopping Cart. • User Authentication. • Online Collaboration Tools.