Sunday, 7 October 2018

What is the right amount of swap space?


What is the right amount of swap space?

Many years ago, the rule of thumb for the amount of swap space that should be allot on the hard drive was 2X the amount of RAM installed in the computer (of course, that was when more computers' RAM was measured in KB or MB). Therefore, if the computer has 64 kb of RAM, 128 kb swap partition will be the optimum size.This rule took into account the facts that RAM sizes were generally quite small at that time and that allocating more than 2X RAM for swap space did not boost performance. With more than twice RAM for swap, most systems spent more time thrashing than absolutely performing useful work.
RAM has become an reasonable commodity and most computers these days have amounts of RAM that boost into tens of gigabytes. Most of the new users have at least 8GB to 32GB of RAM, my main workstation has 64 GB.
When dealing with computers having big amounts of RAM, the reduce performance factor for swap space is far lower than the 2X multiplier. The Fedora 28 online Installation counselor, which can be found online at Fedora Installation Guide, defines current reasoning about swap space allocation. I have added below any analysis and the table of recommendations from that document.
The following table add the recommended size of a swap partition depending on the amount of in your system and whether you want enough memory for your system to hibernate. The recommended swap partition size is established naturally during installation. To allow for hibernation, however, you will want to compile the swap space in the custom partitioning stage.
Table 1: Fedora 28 documentation system requirements for swap space

Amount of system RAM
Recommended swap space
Recommended swap with hibernation
less than 2 GB
2 times the amount of RAM
3 times the amount of RAM
2 GB - 8 GB
Equal to the amount of RAM
2 times the amount of RAM
8 GB - 64 GB
0.5 times the amount of RAM
1.5 times the amount of RAM
more than 64 GB
workload dependent
hibernation not recommended

At the border between each field listed above (for example, a system with 2 GB, 8 GB, or 64 GB of system RAM), use attention with regard to chosen swap space and hibernation support. If your system resources grant for it, developing the swap space may lead to best performance.
Of course, more Linux administrators have their own concept about the applicable amount of swap space—as well as elegant much everything else. Table 2, below, contains my recommendations based on my particular experiences in different environments. These may not task for you, but as with Table 1, they may help you get started.
Table 2: Recommended system swap space per the author
Amount of RAM
Recommended swap space
≤ 2GB
2X RAM
2GB – 8GB
= RAM
>8GB
8GB
One discussion of these two tables is that adding more swap space instead of a point will also cause fatigue before filling the swap space due to the amount of RAM being developed.
If you have very little virtual memory following these recommendations, you should add as much RAM as possible instead of more swap space. Use the most appropriate environment for you, all recommendations will affect system performance.Based on the conditions of the Linux environment, it takes time and effort to experiment and make changes.

Adding non-LVM disk environment for more swap space

Since the swap space requirements on a host where Linux is installed, it may be necessary to modify the amount of swap space defined for the system.This process can be used for any common case where you need to increase the amount of swap space. It assumes that there is enough free disk space. This process also assumes that the disk is divided into "raw" EXT4 and the partition is swapped and does not use logical volume management (LVM).

The basic steps to take are simple:
  1. Turn off the existing swap space.
  2. Creating a new swap partition
  3. Reread the partition table.
  4. Configure the partition as swap space.
  5. Add the new partition/etc/fstab.
  6. Turn on swap.
A reboot should not be necessary.
For security reasons, at least make sure that no applications are running and no swap space is used before the exchange. The free or highest order can tell you if the swap space is in use. For added security, you can return to run level 1 or single user mode.

To close all swap space, swap off swap partitions with a command partition:
swapoff -a
Now shows the current partition on the hard drive.
fdisk -l
This will display the current partition table on each drive. Current swap is recognized by partition number.
Start fdisk in interactive mode with the command:
fdisk /dev/<device name>
For example:
fdisk /dev/sda
At this point, fdisk is now interactive and will work only on specified disk drives.
To create a new swap partition, use the fdisk p subcommand to verify enough free space on the disk. The location on the hard drive is displayed in the 512-byte block and the cylinder number starts and ends, so you may need to do some calculation to determine the available space between and between the allocated partition.
Create a new swap partition with n subcommands. Fdisk will ask you the initial cylinder. By default, it selects the minimum number of available cylinders. If you want to change it, type the number of initial cylinders.

The Fdisk command now allows you to enter the partition size in a variety of formats, including the final format number or byte, KB or MB size. Enter 4000 M, which will provide approximately 4 GB of space on the new partition (for example) and press Enter.

To verify that the partition was created as specified, use the p subcommand. Note that the partition can not be exactly as you have specified unless you use the last cylinder number. The Fdisk command can allocate disk space to the entire cylinder, so your division may be smaller or larger than your specified. If the partition is not what you want, you can remove it and make it again.

Now you need to specify that the new partition is a swap partition. The subcommand T allows you to specify the type of partition. Then type T to specify the partition number. For hex code partition you can type, type 82, for the Linux swap partition type, and press Enter.

If you are satisfied with the partition created, use the w sub-command to write a new partition table on the disk. After completing the compilation of the modified partition table, the fdisk program will exit and return to the command prompt. When fdisk terminates writing a new partition table, you may receive the following message:
The partition table has been altered!
Calling ioctl() to re-read partition table.
The kernel still uses the old table.
In the next reboot, the new table will be used.
Syncing disks.
At this point, you use the partprobe command to force the kernel to read the partition table again so that you don't need to reboot.
partprobe
Now use the fdisk -l command to list the partitions. The new swap partition should be the partition listed. Make sure the new partition type is "Linux swap".
It is necessary to modify the /etc/fstab file to point to the new swap partition. The current line might look like this:
LABEL=SWAP-sdaX   swap swap  defaults 0 0
Where x is the partition number. Add a new line based on the location of the new swap partition that looks similar:
/dev/sdaY         swap swap  defaults 0 0
Be sure to use the correct partition number. Now you can perform the final step of creating a swap partition. Use the mkswap command to define a partition as a swap partition.
mkswap /dev/sdaY
Using the command the final step is to turn on swap:
swapon -a
Your new swap partition is now online with a pre-existing swap partition. You can verify it using free or top command.

Adding swap to an LVM disk environment

If your disk settings use LVM, it will be easier to change the swap space. Again, it assumes that space is available in the volume group in which the current swap volume is located. By default, the Fedora Linux installation process in an LVM environment makes the swap partition a logical volume. This is easy to do because you can easily increase the size of the swap volume.
Here are the steps needed to increase the amount of swap space in LVM environments:
  1. Turn off all swap.
  2. The size of the logical volume designated can be increased for swap.
  3. Configure the resized volume as swap space.
  4. Turn on swap.
Let’s first verify that swap exists and a logical volume using the lvs command (list logical volume).

You can see that the current exchange size is 8 GB. In this case, adding 2 GB to this swap volume will help. First of all, stop the current swap. If you are using swap space, you may have to end an ongoing program.
swapoff -a
Now increase the size of the logical volume.
to make this entire 10GB partition into swap space run the mkswap command
Turn swap back on.
[root@studentvm1 ~]# swapon -a
[root@studentvm1 ~]#

Now use the list block device command to verify that the new swap space exists. Again, there is no need to reboot.
For verification a user can also use the swapon -s command, or top, free, or any of several other commands that are available.

Please note that the inputs of device-specific files are displayed or required in different commands. There are several ways to access a specific device in the / dev directory. My article "Management Tools in Linux" has more information about the / dev directory and its contents.


Thursday, 4 October 2018

An introduction to swap space on Linux systems - linux training


An introduction to swap space on Linux systems

Learn how to adjust the amount of swap space applicable on your Linux system, and how much you actually need.

linux training in chandigarh Swap space is a simple aspect of computing today, regardless of operating system. Linux benefits swap space to boost the amount of virtual memory applicable to a host. It can use one or extra dedicated swap partitions or a swap file on a daily filesystem or logical volume.
More Linux resources

 


A typical computer has two basic types of memory. The first type of random access memory (RAM) it is used to store data and programs while they are actively used by the computer.Computer programs and data can not be used until they are stored in RAM. Ram is volatile memory; That is, if the computer is locked then the data stored in the RAM will be lost.

Hard drives are used for long-term storage of magnetic media data and programs. Magnetic media is non-volatile; data is stored on disk residues, even when powered off from the computer.The CPU (central processing unit) cannot straight access the programs and data on the hard drive; it must be copied into RAM first, and that is where the CPU can access its programming information and the data to be operated on by those guidance. During the boot process, a computer copies special operating system programs, such as the kernel and init or systems, and data from the hard drive into RAM, where it is accessed precisely by the computer’s processor, the CPU. 

Swap space 
Swap space is the second type of memory in stylish Linux systems. The primary function of swap space is to substitute disk space for RAM memory when actual RAM fills up and more space is required.
For example, consider you have a computer system with 8GB of RAM. If you start up programs that don’t fill that RAM, all is fine and no swapping is needed. But think the spreadsheet you are working on grows when you add more rows, and that, plus all else that's running, now fills all of RAM. Without swap space feasible, you would have to pause working on the spreadsheet until you could free up some of your  RAM by closing down some other programs.
The kernel uses a memory authority program that detects blocks, aka pages, of memory in which the contents have not been used newly. The memory management program swaps sufficient of these relatively rarely used pages of memory out to a specific partition on the hard drive exactly designated for “paging,” or swapping. This frees up RAM and cause room for more data to be entered into your spreadsheet. Those pages of memory swapped out to the hard drive are tracked by the kernel memory management code and can be paged back into RAM if they are required.
The overall amount of memory in a Linux computer is the RAM plus swap space and is assign to as virtual memory.

Types of Linux swap 

Linux produce two types of swap space by default, more Linux installations build a swap partition, but it is also possible to use a specifically configured file as a swap file. A swap partition is just what its name implies—a standard disk partition that is label as swap space by the mkswap command.

A swap file can be used if there is no free disk space in which to design a new swap partition or space in a volume group where a logical volume can be build for swap space. This is just a daily file that is created and preallocated to a specified size.Then run the mkswap command to configure it as a swap space. I do not recommend using files for swap space until absolutely necessary.
Thrashing
Thrashing can occur when overall virtual memory, both RAM and swap space, become virtually full. The system absorb so much time paging blocks of memory between swap space and RAM and back that little time is left for real work. The typical symptoms of this are available: The system becomes slow or fully unresponsive, and the hard drive activity light is on actually constantly.
If you can manage to matter a command like free that shows CPU load and memory usage, you will see that the CPU load is very high,At CPU cores in the system the number perhaps as much as 30 to 40 times.
Another symptom is that both RAM and swap space are virtually completely absolutely allocated.
After the fact, see at SAR (system activity report) data can also show these symptoms.I install SAR on various system I work on and use it for post-repair forensic analysis.

Taking PHP Seriously - Virtues of PHP | CBitss technologies


Taking PHP Seriously

Why do everyone choose to build a new project in PHP language? Would you too?
Most developers  who have only casually used PHP know two things about it: that it is a bad language, which they would never choose to use if given the choice; and that the absolute most remarkably effective projects in history utilize it. This isn't exactly a contradiction, yet it should make us  curious. Did Facebook, Wikipedia, Wordpress, Etsy, Baidu, Box all prevail regardless of utilizing PHP?

- Would they all have been better off expressing their application in any other language?Maybe not. PHP-the-language has numerous flaws,  which without a doubt have backed these endeavors off, however PHP environment has ideals which more than compensate for those flaws. What's more, the choices for enhancing PHPs language level imperfections are truly impressive.
On the equalization, PHP training in chandigarh gives better help for building, changing,and operating a successful project than competing environments.  I would begin another project in PHP today, with a reservation or two, yet zero expressions of apologies.

Taking PHP Seriously  - Virtues of PHP | CBitss technologies

Background

Uniquely among modern languages, PHP was born in the web server. Its strengths get tightly in the context of request-oriented, server-side performance. PHP was originally stood for "personal home page". It was first released by Rasmus Lerdorf in 1995, which included guest books and hit counters to support small, simple dynamic web applications that were popular in the early days of the web. From the beginning of PHP, it has been used for more complex projects than its creators.

It has been done through several major modifications, each of which has brought new mechanisms to tilt these complicated applications. Today, in 2018, it is a feature rich member of the mixed-paradigm productivity language family, which includes JavaScript, Python, Ruby and Lua. If you've touched PHP recently then the contemporary PHP codebase can surprise you with  traits, closures, and generators.

Virtues of PHP

PHP many things are very deep, and typically, right.
First of all, the state. Every web request begins with a completely empty slate. Its namespaces and globals are irregular, except for standard globals, functions and classes, which provide primitive functionality and life support. By introducing each request from a known state, we get a kind of organic fault isolation; If the request T fails by the software defect and fails, then this bug does not interfere directly in the subsequent requests T + 1 execution.  State does reside in places other than the program heap, and it is possible to mess database, or memcache, or file system. But PHP shares that weakness with all imaginable environments that allows persistence. Separating a heap of requests from each other reduces the cost of most programs defects.

Second, concurrently An individual web request runs in a PHP thread. This seems like a silly limitation for the first time. But since your program is executed in the context of a web server, we have a natural source of  concurrency available: Web request Unleashing the localhost (or even another web server) unlimited, provides shared-nothing, copy-in / copy-out mode to exploit parallelism. In practice, it is safer and more flexible for error than the lock-and-share-state approach, which provides mostly general-purpose languages.

Lastly, the fact that PHP programs work at the request level, this means that the programmer workflow is fast and efficient, and remains as fast as the application changes. Many developer productivity languages ​​claim it, but if they do not reset the state for each request, and the main event loop shares program-level status with the request, they almost always take some startup time.

For a specific Python application server, for example, the debugging cycle looks like something like "Think; Edit; Restart the server; Send some test request." Even if "restart the server" only takes a few seconds, which takes a 15-30 second big cut, our finite human brain has to catch the most fragile situation.
I claim that PHP training in chandigarh is simple "Think; Edit; Reload the page" cycle makes developers more productive. During the life cycle of a long and complex software project,these productivity gains compound.