0% found this document useful (0 votes)
39 views4 pages

Advance Programming Week 7-8

Caches are used to temporarily store data, like web pages or application files, to improve access speed and performance. There are different types of caches, including CPU caches, browser caches, and database caches. Caches improve performance by storing recently or frequently used data locally so it can be accessed much faster than from a hard drive or web server.

Uploaded by

jellobayson
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
39 views4 pages

Advance Programming Week 7-8

Caches are used to temporarily store data, like web pages or application files, to improve access speed and performance. There are different types of caches, including CPU caches, browser caches, and database caches. Caches improve performance by storing recently or frequently used data locally so it can be accessed much faster than from a hard drive or web server.

Uploaded by

jellobayson
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Cache

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

How does a cache work?

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

Cache is important for several reasons:

• reduces latency for active data.

• It diverts I/O to cache, reducing I/O operations to external storage and lower levels of storage area network

• Data can remain permanently in traditional storage or external storage arrays.

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.

Other types of software that use caches include the following:

• 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

• databases, where they can reduce latency in database query

What are the benefits of caches?

• Performance. Storing data in a cache allows a computer to run faster.

• Offline work. Caches also let applications function without an internet connection

• Resource efficiency. fast access to cache conserves battery power

What are the drawbacks of caches?

There are issues with caches, including the following:

• Corruption. Caches can be corrupted, making stored data no longer useful.

• 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

What does clearing a cache do and how often should it be done?

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.

How do you clear a cache?

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.

• On Microsoft Windows machines, press Ctrl-Shift-Delete.

• On Apple Macs, press Command-Shift-Delete.

• Google Chrome: Press Ctrl-Shift-Delete if on a Windows machine, or Command-Shift-Delete on a Mac.

• 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.

• Click Cached images and files. • Click Clear data

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

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

Adjusting Settings: Tweaking parameters like operating system configurations,

Load Balancing: Distributing workload across resources efficiently

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

• Temporary Storage. • Frequent Access. • Quick Retrieval

Use cases Scenario: Consider a website with a product catalog.

• 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

Use cases Scenario:

Consider a scientific simulation software.

• Computational Reuse • Simulation Steps • Stored Results • Efficient Iterations

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

How do distributed apps work?

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.

Types of distributed app architecture

Distributed applications need to be hosted on more than one server to run.

• Client-server. • Service-oriented architecture. • Micro services architecture. • Peer-to-peer.

Examples of distributed applications

• Accept payment from customers at checkout.

• Update the customer list with new registrations.

• Answer customer questions using a chat bot

Other examples of distributed applications: • banking applications; • stock exchange applications;

• 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:

• Data Integrity • Efficiency • Scalability

User Authentication and Session Security

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.

Here's an overview of how user authentication works:

• User Provides Credentials. • Verification: • Access Granted or Denied • Token-based Authentication

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.

Here's an overview of how session security works:

• Session Creation: • Session Storage • Session Tokens. • Session Expiry and Invalidation

Use Case Examples:

• Online Banking: Authentication. • Email Services. • Social Media Platforms

Advantages:

• Access Control. • Personalization •Security:

Disadvantages:

• Security Risks. • User Experience • Maintenance Overhead

Session Handling

is a crucial aspect of web development that involves managing user sessions to maintain state information between HTTP requests.

Here's an overview of how session handling works:

• Session Initiation • Data Storage • Session Tracking • Expiration and Invalidation • Session Security Measures:

Use Case Examples: • E-commerce Shopping Cart. • User Authentication. • Online Collaboration Tools.

Advantages: • State Persistence • Simplified Development • Scalability

Disadvantages: • Security Concerns • Resource Usage • Complexity in Distributed Systems

You might also like