Subnetting is the process of splitting a CIDR (Classless InterDomain Routing ) block into smaller blocks.
Subnetting
When you create a VPC you are required to enter a CIDR block range.
A lot of consideration must be put when choosing the CIDR block, because we need to ensure there will be enough IP addresses for our instances within each subnet, and because, as we see later, CIDR block should never overlap.
CIDR guidelines/considerations
block size must be between /16 and /28
CIDR block must not overlap any existing blocks associated with the VPC
CIDR block size can't be increased or decreased
AWS recommends using CIDR blocks from RFC 1918 ranges
when setting the size of the subnets keep in mind that first four and last IP addresses are not available for use
bigger CIDR blocks give more flexibility but smaller subnets are ok for most use cases
VPC CIDR
Imagine we have a VPC CIDR Block of 10.0.0.0/16 and that we want to create 16 subnets. To do so, we use a mask of /20 (which gives us a total of 4096 hosts (16*256).
Considering that for each subnet 5 addresses ( first 4 and the last one) are reserved by AWS, we are left with 251 hosts in each subnet for our instances
IP Subnets calculator
If you want to dig more into this topic this is one of the best articles about VPC Design / CIDR Blocks and Subnetting I have ever read. Highly suggested.
Also these tools proved very useful to better understand these CIDR Blocks and masks: