How to Setup a LAMP Stack with MySQL HeatWave – Part 2/5

To build the infrastructure you will both need an account and a tenancy within Oracle Cloud Infrastructure (OCI) account. If you do not have these, then please click here. Note the Oracle very often offers a free trial period which provides more than enough credits to complete the architecture described in this blog.Planet MySQL

How to Setup a LAMP Stack with MySQL HeatWave – Part 3/5

Whilst not part of the LAMP stack per-se, you will need a MySQL client in order to be able to upload and make changes to your database schema. MySQL clients that could be used include: the traditional MySQL client; MySQL shell; MySQL Workbench as well as phpMyAdmin. At the stage the most efficient of these clients will be MySQL Shell.Planet MySQL

MySQL Window Functions Part 2

Window functions in MySQL offer developers an efficient way to view and compare data across a result set. In this post we will talk about using aggregate functions as window functions and break down the different sections of a window frame.Planet MySQL

MySQL & UUIDs

More and more people are using UUID’s to identify records in their database.

As you already know, for MySQL’s storage engine (InnoDB) the primary key is very important ! (for performance, memory and disk space).

See the following links:

Problems

There are 2 major problems having a UUID as Primary Key in InnoDB:

  1. generally they are random and cause clustered index to be rebalanced
  2. they are included in each secondary indexes (consuming disk and memory)

Let’s have a look at this example:

MySQL > CREATE TABLE my_table ( 
       uuid VARCHAR(36) DEFAULT (UUID()) PRIMARY KEY, 
       name VARCHAR(20), beers int unsigned);
...

MySQL > SELECT * FROM my_table;
+--------------------------------------+---------+-------+
| uuid                                 | name    | beers |
+--------------------------------------+---------+-------+
| 17cd1188-1fa0-11ed-ba36-c8cb9e32df8e | Kenny   |     0 |
| 17cd12e2-1fa0-11ed-ba36-c8cb9e32df8e | lefred  |     1 |
| 478368a0-1fa0-11ed-ba36-c8cb9e32df8e | Scott   |     1 |
| 47836a77-1fa0-11ed-ba36-c8cb9e32df8e | Lenka   |     0 |
+--------------------------------------+---------+-------+

Now, let’s insert 2 new records:

MySQL > INSERT INTO my_table (name, beers) VALUES ("Luis",1), ("Miguel",5);

We can check the content of the table:

MySQL > SELECT * FROM my_table;
+--------------------------------------+---------+-------+
| uuid                                 | name    | beers |
+--------------------------------------+---------+-------+
| 17cd1188-1fa0-11ed-ba36-c8cb9e32df8e | Yannis  |     0 |
| 17cd12e2-1fa0-11ed-ba36-c8cb9e32df8e | lefred  |     1 |
| 36f1ce9a-1fa1-11ed-ba36-c8cb9e32df8e | Luis    |     1 |  <--
| 36f1d158-1fa1-11ed-ba36-c8cb9e32df8e | Miguel  |     5 |  <--
| 478368a0-1fa0-11ed-ba36-c8cb9e32df8e | Scott   |     1 |
| 47836a77-1fa0-11ed-ba36-c8cb9e32df8e | Lenka   |     0 |
+--------------------------------------+---------+-------+

We can see that the two new records were not inserted at the end of the table but in the middle. InnoDB had to move two old records to be able to insert the two new before them. On such small table (all records are on the same page) that doesn’t cause any problem, but imagine this table is 1TB large !

Additionally, if we keep the VARCHCAR datatype for our uuid, the primary key could take 146 bytes per row (some utf8 characters can take up to 4 bytes + the 2 bytes marking the end of the VARCHAR):

MySQL > EXPLAIN SELECT * FROM my_table WHERE 
        uuid='36f1d158-1fa1-11ed-ba36-c8cb9e32df8e'\G
 *************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: my_table
   partitions: NULL
         type: const
possible_keys: PRIMARY
          key: PRIMARY
      key_len: 146        <--
          ref: const
         rows: 1
     filtered: 100
        Extra: NULL

Solutions

Of course there are some best practices that MySQL users can follow to avoid those problems:

  1. use a smaller datatype to store their UUIDs: BINARY(16)
  2. store the UUIDs sequentially: use UUID_TO_BIN(..., swap_flag)
    • The time-low and time-high parts (the first and third groups of hexadecimal digits, respectively) are swapped.

Let’s see this in action with the following example:

MySQL > CREATE TABLE my_table2 ( 
           uuid BINARY(16) DEFAULT (UUID_TO_BIN(UUID(), 1)) PRIMARY KEY, 
           name VARCHAR(20), beers int unsigned);

MySQL > SELECT * FROM my_table2;
+------------------------------------+--------+-------+
| uuid                               | name   | beers |
+------------------------------------+--------+-------+
| 0x11ED1F9F633ECB6CBA36C8CB9E32DF8E | Kenny  |     0 |
| 0x11ED1F9F633ECD6FBA36C8CB9E32DF8E | lefred |     1 |
+------------------------------------+--------+-------+

As the UUID is now binary, we need to decode it using the function BIN_TO_UUID() and not forget the swap flag:

MySQL > SELECT BIN_TO_UUID(uuid,1), name, beers FROM my_table2;
+--------------------------------------+--------+-------+
| BIN_TO_UUID(uuid,1)                  | name   | beers |
+--------------------------------------+--------+-------+
| 633ecb6c-1f9f-11ed-ba36-c8cb9e32df8e | Kenny  |     0 |
| 633ecd6f-1f9f-11ed-ba36-c8cb9e32df8e | lefred |     1 |
+--------------------------------------+--------+-------+

And now we can verify that when we add new entries they are added to the end of the table:

MySQL > INSERT INTO my_table2 (name, beers) VALUES ("Scott",1), ("Lenka",5); 

MySQL > SELECT * FROM my_table2;
+------------------------------------+---------+-------+
| uuid                               | name    | beers |
+------------------------------------+---------+-------+
| 0x11ED1F9F633ECB6CBA36C8CB9E32DF8E | Kenny   |     0 |
| 0x11ED1F9F633ECD6FBA36C8CB9E32DF8E | lefred  |     1 |
| 0x11ED1FA537C57361BA36C8CB9E32DF8E | Scott   |     1 |  <--
| 0x11ED1FA537C5752DBA36C8CB9E32DF8E | Lenka   |     5 |  <--
+------------------------------------+---------+-------+

and we can of course decode the UUID and see that without the swap flag, InnoDB would have to rebalance the clustered index:

MySQL > SELECT BIN_TO_UUID(uuid,1), name, beers FROM my_table2;
+--------------------------------------+---------+-------+
| BIN_TO_UUID(uuid,1)                  | name    | beers |
+--------------------------------------+---------+-------+
| 633ecb6c-1f9f-11ed-ba36-c8cb9e32df8e | Kenny   |     0 |
| 633ecd6f-1f9f-11ed-ba36-c8cb9e32df8e | lefred  |     1 |
| 37c57361-1fa5-11ed-ba36-c8cb9e32df8e | Scott   |     1 |  <--
| 37c5752d-1fa5-11ed-ba36-c8cb9e32df8e | Lenka   |     5 |  <--
+--------------------------------------+---------+-------+

And of course, now the size of the primary key is smaller and fixed to 16 bytes. Only those 16 bytes are added to all secondary indexes:

MySQL > EXPLAIN SELECT * FROM my_table2 
        WHERE uuid=UUID_TO_BIN("37c5752d-1fa5-11ed-ba36-c8cb9e32df8e",1)\G
 *************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: my_table2
   partitions: NULL
         type: const
possible_keys: PRIMARY
          key: PRIMARY
      key_len: 16        <---
          ref: const
         rows: 1
     filtered: 100
        Extra: NULL

UUID v1

MySQL generates UUID v1 as described in RFC4122.

  • UUID v1 : is a universally unique identifier that is generated using a timestamp and the MAC address of the computer on which it was generated.
  • UUID v4 : is a universally unique identifier that is generated using random numbers.

With UUID v4m it’s not possible to generate any sequential ouput and this is why those random UUID should never be used as Primary Key with InnoDB.

UUID v4

Some developers keep asking about UUIDv4 and how to generate them for MySQL. Browsing the Internet, you can find several store procedures trying to achieve this.

This one, found on StackOverflow, is maybe my favorite:

CREATE FUNCTION uuid_v4s()
    RETURNS CHAR(36)
BEGIN
    -- 1th and 2nd block are made of 6 random bytes
    SET @h1 = HEX(RANDOM_BYTES(4));
    SET @h2 = HEX(RANDOM_BYTES(2));

    -- 3th block will start with a 4 indicating the version, remaining is random
    SET @h3 = SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3);

    -- 4th block first nibble can only be 8, 9 A or B, remaining is random
    SET @h4 = CONCAT(HEX(FLOOR(ASCII(RANDOM_BYTES(1)) / 64)+8),
                SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3));

    -- 5th block is made of 6 random bytes
    SET @h5 = HEX(RANDOM_BYTES(6));

    -- Build the complete UUID
    RETURN LOWER(CONCAT(
        @h1, '-', @h2, '-4', @h3, '-', @h4, '-', @h5
    ));
END

Unfortunately this function cannot be used as default expression for a column.

I also wrote a component using boost’s uuid library: https://github.com/lefred/mysql-component-uuid_v4

But this new function is also not usable as default value expression.

MySQL error code MY-003770 (ER_DEFAULT_VAL_GENERATED_NAMED_FUNCTION_IS_NOT_ALLOWED): Default value expression of column '%s' contains a disallowed function: %s.

This means that every new record needs to provide the uuid column… this is not too complicated anyway.

Let’s see an example:

MySQL > install component "file://component_uuid_v4";

MySQL > select uuid_v4() ;
+--------------------------------------+
| uuid_v4()                            |
+--------------------------------------+
| 9944272b-e3f9-4778-9c54-818f0baa87da |
+--------------------------------------+
1 row in set (0.0002 sec)

Now we will create a new table, but as recommended, we won’t use the uuid as Primary Key ! We will use a new feature of MySQL 8.0.30: GIPK Mode !

GIPK stands for Generated Invisible Primary Key, check the manual for more info.

MySQL > SET sql_generate_invisible_primary_key=1;
 
MySQL > CREATE TABLE my_table3 (   
            uuid BINARY(16) NOT NULL UNIQUE,
            name VARCHAR(20), beers INT UNSIGNED);

MySQL > SHOW CREATE TABLE my_table3\G
*************************** 1. row ***************************
       Table: my_table3
Create Table: CREATE TABLE `my_table3` (
  `my_row_id` bigint unsigned NOT NULL AUTO_INCREMENT /*!80023 INVISIBLE */,
  `uuid` binary(16) NOT NULL,
  `name` varchar(20) DEFAULT NULL,
  `beers` int unsigned DEFAULT NULL,
  PRIMARY KEY (`my_row_id`),
  UNIQUE KEY `uuid` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Now let’s insert some records and see if they are inserted sequentially and if the UUID’s value is completely random:

MySQL > INSERT INTO my_table3 (uuid, name, beers) 
        VALUES (UUID_TO_BIN(uuid_v4()),'Kenny', 3),
               (UUID_TO_BIN(uuid_v4()), 'lefred', 1);

MySQL > SELECT * FROM my_table3;
+------------------------------------+--------+-------+
| uuid                               | name   | beers |
+------------------------------------+--------+-------+
| 0x5A28E5482CDF4B3D89A298ECA3F3703B | Kenny  |     3 |
| 0x94662BF4DC2F469489D868820B7B31E5 | lefred |     1 |
+------------------------------------+--------+-------+

MySQL > SELECT BIN_TO_UUID(uuid), name, beers FROM my_table3;
+--------------------------------------+--------+-------+
| bin_to_uuid(uuid)                    | name   | beers |
+--------------------------------------+--------+-------+
| 5a28e548-2cdf-4b3d-89a2-98eca3f3703b | Kenny  |     3 |
| 94662bf4-dc2f-4694-89d8-68820b7b31e5 | lefred |     1 |
+--------------------------------------+--------+-------+

So far, so good.. let’s add some more records:

MySQL > INSERT INTO my_table3 (uuid, name, beers) 
        VALUES (UUID_TO_BIN(uuid_v4()),'Scott', 10), 
               (UUID_TO_BIN(uuid_v4()), 'Lenka', 0);

MySQL > SELECT BIN_TO_UUID(uuid), name, beers FROM my_table3;
+--------------------------------------+--------+-------+
| bin_to_uuid(uuid)                    | name   | beers |
+--------------------------------------+--------+-------+
| 5a28e548-2cdf-4b3d-89a2-98eca3f3703b | Kenny  |     3 |
| 94662bf4-dc2f-4694-89d8-68820b7b31e5 | lefred |     1 |
| 615fae32-d6c8-439c-9520-5d3c8bfa934b | Scott  |    10 |
| 80a01a29-489b-419d-bca1-05a756ad9d9d | Lenka  |     0 |
+--------------------------------------+--------+-------+

We can see that indeed, the UUIDs are completely random and sequentially added to the table. The reason of that optimal sequential insertion is that the invisible Primary Key is an auto_increment.

It’s possible to also display it on demand:

MySQL > SELECT my_row_id, BIN_TO_UUID(uuid), name, beers FROM my_table3;
+-----------+--------------------------------------+--------+-------+
| my_row_id | bin_to_uuid(uuid)                    | name   | beers |
+-----------+--------------------------------------+--------+-------+
|         1 | 5a28e548-2cdf-4b3d-89a2-98eca3f3703b | Kenny  |     3 |
|         2 | 94662bf4-dc2f-4694-89d8-68820b7b31e5 | lefred |     1 |
|         3 | 615fae32-d6c8-439c-9520-5d3c8bfa934b | Scott  |    10 |
|         4 | 80a01a29-489b-419d-bca1-05a756ad9d9d | Lenka  |     0 |
+-----------+--------------------------------------+--------+-------+

Conclusion

In summary, if you want to use UUID’s in MySQL, it’s recommended to use UUID v1, those generated by MySQL, and store them as binary using the swap flag.

If for some reason you need UUID v4, it is recommended to let MySQL and InnoDB handle the primary key by enabling GIPK mode.

Enjoy MySQL !

Planet MySQL

Remove Sensitive Information from Laravel Apps

https://laravelnews.imgix.net/images/laravel-scrubber-featured.png?ixlib=php-3.3.1

Laravel Scrubber is a Laravel package to scrub sensitive information that breaks operational security policies from being leaked on accident or not by developers.

You can use this package in a few ways:

First, this package detects log messages and context patterns and scrubs them:

1Log::info('some message', [

2 'context' => 'accidental',

3 'leak_of' => [

4 'jwt' => '<insert jwt token here>'

5 ]

6]);

7 

8// testing.INFO: some message {"context":"accidental","leak_of":{"jwt": '**redacted**'}}

9 

10Log::info('<insert jwt token here>');

11 

12// testing.INFO: **redacted**

Second, you can use the scrubber directly to process data in an array and mark it as redacted:

1Scrubber::processMessage([

2 'context' => 'accidental',

3 'leak_of' => [

4 'jwt' => '<insert jwt token here>'

5 ]

6]);

7 

8// [

9// "context" => "accidental"

10// "leak_of" => [

11// "jwt" => "**redacted**"

12// ]

13// ];

14 

15Scrubber::processMessage('<insert jwt token here>');

16// **redacted**

This package also provides customization options, such as configuring the replacement message when data is scrubbed (the default is **redacted**). You can also extend the package by adding custom regex scrubbers.

You can start with Laravel Scrubber by checking out the project on GitHub at YorCreative/Laravel-Scrubber.

Laravel News

Star Trek: Picard’s First Season 3 Trailer Gives Us an Old Crew and a New Ship

https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/80b074910823a81785edccab64c0dc98.png

We knew they were coming, but now we’ve got an idea of the threat that is going to reunite Captain Picard with his classic TNG crew—but they’re going to need a new ship to boldly go in.

As part of today’s Star Trek Day celebrations, Paramount has released the first full trailer for Star Trek: Picard’s third and final season. It teases a mysterious threat to the Federation, that sees Beverly Crusher (the returning Gates McFadden) call on Picard for help—as long as he brings a few old friends along for the ride too.

Star Trek: Picard | Final Season Sneak Peek | Paramount+

The new trailer has a lot going on, beyond our first looks at the returning Doctor Crusher, Riker (Jonathan Frakes), Troi (Marina Sirtis), Geordi (LeVar Burton), and Worf (Michael Dorn). There’s a seemingly dire assault on Federation HQ, mysterious ships latching on to Starfleet vessels, and then there’s Commander Seven of Nine (Jeri Ryan) on a ship called the Titan—but seemingly not the U.S.S. Titan we’ve seen Riker aboard in Lower Decks, unless the trailer’s decieving us with some cleverly spliced footage. Is this perhaps the new Enterprise Patrick Stewart teased back at Comic-Con?

We’ve got a while to speculate. Star Trek: Picard returns to Paramount+ one last time from February 16.


Want more io9 news? Check out when to expect the latest Marvel and Star Wars releases, what’s next for the DC Universe on film and TV, and everything you need to know about House of the Dragon and Lord of the Rings: The Rings of Power.

Gizmodo

Goodbye M16: A Look at the Modern Marine Infantry Rifle M27

https://www.pewpewtactical.com/wp-content/uploads/2022/09/Marines-training-with-the-M27-Photo-Cpl.-Michaela-Gregory-2.webp

In the last few years, the Marine Corps has been modernizing its infantry forces en masse.

The average Marine Infantryman has seen a significant upgrade in their guns and gear in the last decade. 

Marine fires the M27 (Photo Cpl. Michaela Gregory)
Marine fires the M27 (Photo: Cpl. Michaela Gregory)

In the wake of F-35s, remote control missile launching trucks, and drones, the infantry rifle doesn’t seem all that special. 

Or is it?

Today, we’re going to walk through the current infantry rifle and the gear that adorns it. If you’ve been curious about what Marines are carrying (or what to grab similar gear for your own rifle), keep reading!

Table of Contents

Loading…

How Did We Get Here?

The Marine Corps created the A2, for better or worse, and stuck to the A4 model of the gun.

Everyone moved to the M4, but the Marine Corps clung to the M16A4 for longer than necessary. 

The M4 saw adoption by the infantry in 2015, and only two years later, the M27 would go on to be the rifle fielded by infantry forces.

Putting on that Uniform Is the Only Way You’ll get to shoot a real M4.
M4

Marines picked up the M27 in 2009 and began issuing the gun in 2010, starting with the 2nd Battalion 7th Marine regiment. 

The M27 would replace the M249 SAW and would become an automatic rifle tasked with laying down suppressive fire. Marines in Afghanistan fell in love with the weapon, and the Marine Corps was impressed. 

Ya’ Boy with an ACOG equipped M249 Helmand Province Afg 2009
Ya’ boy with an ACOG equipped M249 Helmand Province Afg 2009

Impressed enough, they replaced the M4 for infantry forces without needing a very long and drawn-out testing procedure. 

By now, the average active-duty infantryman is armed with an M27. It seems as though Marines in weapons platoons and companies are still carrying the M4. 

The Infantry Rifle 

Look at the M27 and the M4. They look pretty dang similar, right? We can call it Stoner’s grandchild. 

Well, not just Stoner’s. It has some Hans in it too.

HK designed the HK 416, a piston-driven rifle that’s very clearly related to the M4 series of rifles. To put it simply, the HK 416 is an M4 with the short-stroke gas piston of the G36. 

A student assigned to the U. S. Army John F. Kennedy Special Warfare Center and School fires a German HK 416 during foreign weapons training at Fort Bragg. (U.S. Army photo by K. Kassens)

HK took the 416, made a few changes to accommodate the Marine Corps, and called it good. The differences are minimal, and it’s the same rifle at its core.

That base Marine Corps rifle utilizes a 16.5-inch barrel, features a collapsible stock, and utilizes the same STANAG magazines. 

Clearly, we aren’t ready for M-LOK in the military because the Marines clung to the quad rail they know and love. 

FN 15 quad rail
Livin’ that quad rail life.

This was the first time Marines got an ambidextrous safety, but they didn’t bring the HK 416 A5 total ambidextrous controls. The rifle might be considered a carbine, but it can be rather hefty at 7.9 pounds. 

While the M27 might be the primary rifle, we also need to mention the M38.

The M38 is the DMR variant of the weapon, and the only real difference is the optic equipped to the weapon. 

Lance Cpl. Edgar Cervantes fires M38 during training (Photo: Gunnery Sgt. T. T. Parish)
Lance Cpl. Edgar Cervantes fires M38 during training (Photo: Gunnery Sgt. T. T. Parish)

Marine Corps Optics 

Speaking of optics, the Marine Corps is in a transition period. They are currently fielding three optics with the various rifles in their infantry squads. 

Trijicon 3.5×35 BAC with RMR 

Trijicon 3.5x35 BAC
Trijicon 3.5×35 BAC

When the M27 hit the fleet, the first optic adopted was the Trijicon 3.35×35 with an RMR riding backup. 

Marines have long used the ACOG series of optics on M4s and M16A4s, and it’s been a  successful team-up. The new model, the SU-258/PVQ Squad Day Optic, dialed magnification back a hair. 

Trijicon TA-02 Acog .410 Birdshot Damage
Did we shoot an ACOG with birdshot?? Yes, we did.

We also saw the move from the chevron optic to the donut. Marines were often trained to use an occluded shooting method with the old ACOG. 

Available Coupons

It works but isn’t perfect. The Marine Corps added a Trijicon RMR to the top of the optic to fix this. 

RMR Type 2 RM06 3.25 MOA
RMR Type 2 RM06 3.25 MOA

Using a red dot is more straightforward than using the occluded shooting technique and seemingly faster and potentially more precise.

This setup presents Marines with a durable and straightforward design for engagements at the average infantry range. 

Best Pistol Red Dot
475

at Brownells

Prices accurate at time of writing

Prices accurate at time of writing

Available Coupons

Trijicon 1-8X VCOG 

The Marine Corps plans to replace the ACOG with the Trijicon VCOG. The VCGO presents the first mass-adopted LPVO for the United States military and will give Marines a very versatile and capable 1-8X level of magnification. 

LPVOs are taking over the world of optics, and it’s interesting to see the Marines being early adopters.

Trijicon 1-8X VCOG 
Trijicon 1-8X VCOG 

The VCOG allows Marines to have an optic that works equally well at close and long ranges. From the ground up, the optic is designed to address the needs of the military. 

Trijicon designed the optic with a first focal plane configuration, so the reticle grows and shrinks as the magnification increases and decreases. The reticle’s design ensures it can be used effectively at nearly any range. 

Inside sits a segmented circle that’s massive. Since it shrinks when the magnification is low, it works much like a red dot at lower magnifications.

Trijicon 1-8X VCOG 
Trijicon 1-8X VCOG 

As the magnification increases, the BDC, wind calls, and illuminated crosshair becomes large and more in play for longer-range shots. 

It’s a well-designed reticle that’s simple but versatile. Trijicon equipped the VCOG with 11 brightness settings, including two night vision settings.

Marines are amphibious by nature, and the VCOG can be submerged to 66 feet, so ship to shore won’t be an issue. 

1979

at OpticsPlanet

Prices accurate at time of writing

Prices accurate at time of writing

Available Coupons

Leupold TS-30A2 MARK 4 MR/T 2.5-8X 

Designated marksmen will have their M38s equipped with the Leupold TS-30A2 MARK 4 MR/T optic. 

Marines wielded this optic on the Mk 12 DMRs used by Marine Corps designated marksmen, so the Marines had them in inventory and had institutional knowledge of the platform. 

Plus, Marines didn’t break it in the GWOT, so it’s tough. This optic uses a 2.5-8X magnification range with a 36mm objective lens.

Leupold TS-30A2 MARK 4 MR/T 2.5-8X 
Leupold TS-30A2 MARK 4 MR/T 2.5-8X 

The turrets are fingertip adjustable, the reticle allows for range estimation, and the optic is rugged, well made, and water, shock, and fog proof. 

Interestingly, with the adoption of the VCOG 1-8X being the new optic of choice, the older MARK 4 might give DMs an outdated optic. The MARK 4 is an SFP design and doesn’t have the same versatility as the 1-8X. 

Marine Corps Gear

Harris 9-13 S-LM Bipod 

Harris 9-13 S-LM Bipod
Harris 9-13 S-LM Bipod

Marines love the Harris bipods. They’ve been in use in various precision rifles and DMRs for decades now. Automatic fire requires stability to control, and bipods lend stability. 

As soon as the M27 replaced the SAW, the Marine Corps adopted a bipod to provide supportive fire. 

From photos, the bipod doesn’t seem to be equipped for every M27 in the Marine Corps and seems to be reserved for Marines in the DMR and automatic rifleman role. 

Harris 9-13 S-LM Bipod
Harris 9-13 S-LM Bipod

The 9-13 numbers reference the 9-13 inches of adjustable height. The S-LM bipod uses notched legs that can be adjusted independently of each other.

With the S-LM series, the bipod legs deploy automatically with spring-loaded action. These legs make the bipods easier to adjust when prone and when dealing with uneven terrain. 

Harris bipods are surprisingly affordable for their quality. They can take a serious beating and cost less than $100. 

113

at Amazon

Prices accurate at time of writing

Prices accurate at time of writing

Available Coupons

Magpul Gen3 PMAG

With the adoption of the Magpul Gen3 PMAG, the circle is complete.

What do I mean? Well, Magpuls founder served as a Marine, and with the adoption of their flagship product, the circle of Jarhead completed itself. 

What can I say about PMAGs?

PMAG LR/SR Gen M3
PMAG LR/SR Gen M3

They are the premier polymer magazine. Every generation sees massive improvements that most shooters never notice.

When the M27 first rolled out, the Gen3 hadn’t seen the light of day, and the Gen2 magazines had issues with the M27. 

This led the Marine Corps to ban the use of PMAGs, and my unit banned them while we were deployed, even though we had zero M27s at this time. Common sense isn’t always common. 

PMAGs Gen 2 Vs Gen 3 (4)
PMAGs Gen 2 Vs Gen 3

Anyway, Magpul went back to the drawing board and made changes that allowed the Gen3 PMAGs to work flawlessly in the M27. The Gen3 Pmags use a stronger polymer, a more aggressive grip texture, and improved upon the famed design. 

This made the most dependable PMAG ever created, and they are now the standard-issue magazine of the United States Marine Corps.

15

at Gunmag Warehouse

Prices accurate at time of writing

Prices accurate at time of writing

Available Coupons

Blue Force Gear VCAS Sling 

Before the advent of the Blue Force Gear VCAS sling, it was a dark time. As a Marine, you had only a few choices. You could use a 3-Point, but 3-points are a mess of straps and buckles that is a real pain in the ass. 

You could use a 1-point which meant the rifle would be bouncing around and occasionally swinging into your crotch area and often made letting the weapon hang quite uncomfortable.

Then the VCAS or Vickers Combat Application Sling rescued us. 

Blue Force Gear Vickers Sling
Blue Force Gear Vickers Sling

My unit got them fairly early, and it changed my life and how I carried my rifle. The tactical 2-point became the dominant option, and the VCAS remains the issued sling of the Marine Corps and the M27. 

The VCAS is made from durable 1.25-inch webbing and features a ton of adjustment. You can adjust the sling for armored or nonarmored use. A quick-adjust pull tab makes it easy to adjust the sling rapidly. 

Vickers Sling Pull Tab
Vickers Sling Pull Tab

When properly set up, a user can adjust the sling to have the rifle hanging loose and easy to maneuver, but it can be tight enough to go hands-off in the pull of a tab. 

When tightened, it’s easy to climb, carry a wounded comrade, and more. In terms of durability, well, I still have mine, going on over a decade now, and it still functions perfectly. 

54

at Brownells

Prices accurate at time of writing

Prices accurate at time of writing

Available Coupons

Knights Armament NT4 Suppressor

Every Marine infantryman will also have his rifle equipped with a suppressor.

Yep, it’s one of the first wide-scale issuing of cans amongst a conventional military force. The USMC has been experimenting with suppressors in the infantry for years and only recently pulled the trigger. 

The suppressor of choice is the Knight’s Armament NT4.

Knights Armament NT4 
Knights Armament NT4 

The NT4 is an absolute workhorse and has been kicking around since the late 90s. It’s not the most modern suppressor but seems to offer exactly what the Marine Corps wants as a price point they can stomach. 

It’s known to be quite rugged, and you want rugged when it comes to Marines. 

1525

at Capitol Armory

Prices accurate at time of writing

Prices accurate at time of writing

Available Coupons

PEQ 16 Laser Aiming Unit

The Marine Corps officially adopted the PEQ-16 to replace the older PEQ-15. The PEQ 16 offered Marines a laser aiming unit with a built-in weapon light. The weapon light is pitiful, with a mere 125 lumens of white light. 

PEQ-16
PEQ-16

Although it’s rare to use white lights when NVGs and IR lasers typically dominate night fighting, in the face of lights from Cloud Defensive, Modlite, and even Surefire, designed in 2008, the 125 lumens of light is a penlight. 

The device also has visible IR lasers, an IR flood setting, and more. It allows Marines to effectively and efficiently aim at night, mark targets, and more. 

Final Thoughts

For as long as I can remember, the Marine Corps was the hand-me-down branch, but they seem to be leading the way in gear and rifles these days. 

The Marine Corps modernization is equipping Marines with some pretty high-speed gear. The rifles will soon be outfitted with cans and LPVOs making them quite modern, albeit quite heavy. 

Marines training with the M27 (Photo: Cpl. Michaela Gregory)
Marines training with the M27 (Photo: Cpl. Michaela Gregory)

Is that a sweet modern setup? Or is a dang near 13-pound rifle just too much? Let me know in the comments below. For guns you can buy, check out our guide to Military Surplus Rifles & Shotguns.

The post Goodbye M16: A Look at the Modern Marine Infantry Rifle M27 appeared first on Pew Pew Tactical.

Pew Pew Tactical