Replacing web sockets with Livewire

Replacing web sockets with Livewire

https://ift.tt/34DS5PW

Up until a few days ago, the real-time UI of Oh Dear (an uptime monitoring SaaS I run) was powered with web sockets. We recently replaced this with Livewire components.

In this blog post, I’d like to explain why and how we did that.

I’m going to assume that you already know what Livewire is. If not, head over to the Livewire docs. There’s even a short video course on there. In short, Livewire enables you to create dynamic UIs using server-rendered partials.

Why ditch web sockets #

There are hundreds of uptime checking services, but most of them look pretty crappy. When my buddy Mattias and I created Oh Dear, we set out the goal to create a beautiful service that is easy to use. We believe that our service doesn’t necessarily has to be unique. By providing a good design, UX, and docs, you can get ahead of a large part of the competition.

One of the things we decided on very early on was that our UI needed to be real-time. We don’t want users to refresh to see the latest results of their checks. When a new user adds their first site to our service, we wanted the whole process to be snappy and display results fast.

This is what that looks like in Oh Dear. After signing up, users can fill out this form. When pressing enter, it gets added to the list, and results are immediately displayed as they come in.

This behavior used to be powered by web sockets. Whenever Oh Dear started and completed a check, it would broadcast events to the front end. The broadcasting itself would be done using Laravel’s native broadcasting features and the Laravel WebSockets package that Marcel and I created. On the front end, we used Laravel Echo to receive the events and a couple of Vue components.

It all worked fine, but it sure added some complexity to our stack. Also, most of the time, once users have set up their sites, they won’t visit our website often again. But we’d still keep broadcasting events. We could avoid this by tracking presence in some way, but this would complicate things even further.

By moving to Livewire, we can ditch all of the things mentioned above entirely. There’s no need for a web sockets server, Echo, and Vue to create the experience in the movie above. In fact, in that movie, Livewire is already being used.

Let’s take a look at these Livewire components.

Displaying the list of sites #

This is what the list of sites looks like.

screenshot of site list

Here is the Blade view that is used to render that screen.

<x-app-layout title="Dashboard" :breadcrumbs="Breadcrumbs::render('sites')"> <div class="wrap"> <section class="card pb-8 cloak-fade" v-cloak> @include('app.sites.list.partials.notificationsNotConfigured') <livewire:site-list /> <div class="flex items-center mt-8" id="site-adder"> <livewire:site-adder /> </div> </section> </div> </x-app-layout> 

So we have two Livewire components going on: site-list and site-adder. In the LivewireServiceProvider you can see

namespace App\Providers; use App\Http\App\Livewire\Sites\SiteListComponent; use App\Http\App\Livewire\SiteSettings\SiteAdderComponent; use Illuminate\Support\ServiceProvider; use Livewire\Livewire; class LivewireServiceProvider extends ServiceProvider { public function boot() { Livewire::component('site-list', SiteListComponent::class); Livewire::component('site-adder', SiteAdderComponent::class); // other components } } 

Next, let’s take a look at the SiteListComponent class and its underlying view. You don’t have to understand it all now. After the source code, I’m going to explain some parts, but I think it’s good that you already take a look at the component as a whole, so you have some context.

namespace App\Http\App\Livewire\Sites; use Livewire\Component; use Livewire\WithPagination; class SiteListComponent extends Component { use WithPagination; protected $listeners = ['siteAdded' => '$refresh']; public int $perPage = 30; public string $search = ''; public bool $onlySitesWithIssues = false; public bool $showSiteAdder = false; public function showAll() { $this->search = ''; $this->onlySitesWithIssues = false; } public function showOnlyWithIssues() { $this->search = ''; return $this->onlySitesWithIssues = true; } public function showSiteAdder() { $this->showSiteAdder = true; } public function hideSiteAdder() { $this->showSiteAdder = false; } public function render() { return view('app.sites.list.components.siteList', [ 'sites' => $this->sites(), 'sitesWithIssuesCount' => $this->sitesWithIssuesCount(), ]); } protected function sites() { $query = currentTeam()->sites()->search($this->search); if ($this->onlySitesWithIssues) { $query = $query->hasIssues(); } return $query ->orderByRaw('(SUBSTRING(url, LOCATE("://", url)))') ->paginate($this->perPage); } protected function sitesWithIssuesCount(): int { return currentTeam()->sites()->hasIssues()->count(); } } 

And this is the content of the view that is being rendered in that render function: app.sites.list.components.siteList.

<div> <div wire:poll.5000ms> <section class="flex items-center justify-between w-full mb-8"> <div class="text-xs"> <div class="switcher"> <button wire:click="showAll" class="switcher-button ">Display all sites </button> <button wire:click="showOnlyWithIssues" class="switcher-button "> Display   with issues </button> </div> </div> <div class="flex items-center justify-end"> <a href="#site-adder" wire:click="$emit('showSiteAdder')" class="button is-secondary mr-4">Add another site</a> <input wire:model="search" class="form-input is-small w-48 focus:w-64" type="text" placeholder="Filter sites..."/> </div> </section> <table class="site-list-table w-full"> <thead> <th style="width: 27%;">Site</th> <th style="width: 14%;">Uptime</th> <th style="width: 14%;">Broken links</th> <th style="width: 14%;">Mixed Content</th> <th style="width: 14%;">Certificate Health</th> <th style="width: 17%;">Last check</th> </thead> <tbody> @forelse($sites as $site) <tr> <td class="pr-2"> <div class="flex"> <span class="w-6"><i class="fad text-gray-700 "></i></span> <a href="" class="flex-1 underline truncate"></a> </div> </td> <td class="pr-2"> <x-check-result :site="$site" check-type="uptime"/> </td> <td class="pr-2"> <x-check-result :site="$site" check-type="broken_links"/> </td> <td class="pr-2"> <x-check-result :site="$site" check-type="mixed_content"/> </td> <td class="pr-2"> <x-check-result :site="$site" check-type="certificate_health"/> </td> <td class="text-sm text-gray-700"> @if($site->latest_run_date) <a href=""> <time datetime="" title=""></time> </a> @else No runs yet @endif </td> </tr> @empty <tr><td class="text-center" colspan="6">There are no sites that match your search...</td></tr> @endforelse </tbody> </table> @if ($sites->total() > $perPage) <div class="flex justify-between mt-4"> <div class="flex-1 w-1/2 mt-4">  </div> <div class="flex w-1/2 text-right text-muted text-sm text-gray-700 mt-4"> <div class="w-full block"> Showing  to  out of  sites </div> </div> </div> @endif </div> </div> 

In the render function, you probably have noticed that the component itself is responsible for getting the sites.

public function render() { return view('app.sites.list.components.siteList', [ 'sites' => $this->sites(), 'sitesWithIssuesCount' => $this->sitesWithIssuesCount(), ]); } protected function sites() { $query = currentTeam()->sites()->search($this->search); if ($this->onlySitesWithIssues) { $query = $query->hasIssues(); } return $query ->orderByRaw('(SUBSTRING(url, LOCATE("://", url)))') ->paginate($this->perPage); } 

Filtering sites #

Notice that $this->onlySitesWithIssues check? Let’s see how that variable is being set. If you take a look at the screenshot of the site list, you’ll notice a little filter on the top with “Display all sites” and “Display sites with issues”.

This is the part of the view that renders that.

<div class="switcher"> <button wire:click="showAll" class="switcher-button ">Display all sites </button> <button wire:click="showOnlyWithIssues" class="switcher-button "> Display   with issues </button> </div> 

Notice that wire:click="showOnlyWithIssues". When the user clicks an element with wire:click the method whose name is in the attribute value will be executed, and the component will be re-rendered. So, in this case, showOnlyWithIssues is executed.

public function showOnlyWithIssues() { $this->search = ''; return $this->onlySitesWithIssues = true; } 

So, here our onlySitesWithIssues instance variable is changed, causing our component to re-render. Because onlySitesWithIssues is now set to true, the sites() method will now filter on sites having issues.

if ($this->onlySitesWithIssues) { $query = $query->hasIssues(); } 

When the component gets rendered, only sites with issues are displayed. Under the hood, Livewire takes care of a lot of things, most notably calling the method on the component when that wire:click element is called, and replacing the HTML of the component on the page when the HTML of the re-rendered version.

Searching sites #

In the top right corner of the site list, you see a search box. When you type something there, you will only see sites who’s name contain your query. Here’s how that works.

In the Blade view, this is the relevant HTML.

<input wire:model="search" class="form-input is-small w-48 focus:w-64" type="text" placeholder="Filter sites..." /> 

Here, another Livewire directive is used: wire:model. This directive will make sure that each time you type something in that element, Livewire will update the instance variable with the same name in the component and re-render the component. By default, this behavior is debounced, meaning that when you type fast, only one request will be made every 150ms.

So, because the search instance variable is changed on the component, it will re-render. In the first line of the sites() method, the value is being used.

$query = currentTeam()->sites()->search($this->search); 

And with this in place, searching sites works. I think it’s kinda amazing that you can have this behavior by merely adding livewire:model in your view, and using that value to scope your query. Sure, you could do this with Vue, but this is way simpler.

For completeness, here’s the scopeSearch that’s on the Site model.

public static function scopeSearch(Builder $query, string $searchFor): void { if ($query === '') { return; } $query->where('url', 'like', "%{$searchFor}%"); } 

Paginating sites #

Laravel natively has excellent support for paginating query results. You only have to call paginate on your query, which we have done in the sites() method.

// in the sites() method return $query ->orderByRaw('(SUBSTRING(url, LOCATE("://", url)))') ->paginate($this->perPage); 

Calling $sites->links() in the view will render URLs with a page parameter. Under the hood of the paginate() method, that query parameter is used to fetch the results of that page. That’s in short how pagination works in Laravel.

Adding pagination support to a Livewire component is super easy with Livewire. You just have to use the Livewire\WithPagination trait on your component. This trait does some magic so the render links don’t contain a URL to your page, but to an internal Livewire route. This is the output of $sites()->links() in the view of Livewire component.

<ul> <li class="page-item active" aria-current="page"><span class="page-link">1</span></li> <li class="page-item"><a class="page-link" href="https://ohdear.app/livewire/message/site-list?page=2">2</a></li> <li class="page-item"><a class="page-link" href="https://ohdear.app/livewire/message/site-list?page=3">3</a></li> <li class="page-item"><a class="page-link" href="https://ohdear.app/livewire/message/site-list?page=4">4</a></li> <li class="page-item"> <a class="page-link" href="https://ohdear.app/livewire/message/site-list?page=2" rel="next" aria-label="Next »"></a> </li> </ul> 

When clicking such a link, Livewire will set the page query parameter in the URL and re-render the component. It’s an elegant solution, and I like that it hooks in so nicely with Laravel’s default pagination.

As a Livewire user, the only thing you needed to do extra was to apply that WithPagination trait. Beautiful.

Updating the list #

As stated earlier, want to have our UI to display the current state, without users having to refresh. If one of the sites displayed in the list goes down, the list should get updated automatically.

The solution for this is straightforward: we’re just going to poll for changes. Livewire comes with support for polling out of the box. At the top of the view you might have noticed this:

<div wire:poll.5000ms> 

This will make Livewire refresh the component automatically every five seconds. To re-render the component in the browser, Livewire makes use of morphdom. This will compare the HTML of the component with the HTML of the re-rendered version. Only the changes will get updated in the DOM, making the cost for re-rendering in the browser very low.

While typing this blog post, I can already feel the screams of some readers: “Freek, what are you doing!?!? This is highly inefficient: it will perform queries and make requests the whole time…”. And yes, that is true.

Using Livewire with polling is a trade-off. One the one hand, we have some more requests/queries, but this only happens when users are looking at their site lists. This won’t happen often. To know the state of their sites, the vast majority of our users rely on the alerts we sent out (via Slack, Mail, Telegram, …), and they won’t be staring at the site list the whole time.

It’s also very nice that Livewire only polls if the browser is displaying the page. When a browser tab is in the background, polling is paused.

By using a little bit of polling, we don’t need to set up web sockets or Vue, and we don’t need to broadcast events the whole time, … It vastly simplifies our tech stack. I think in this case, the trade-off that Livewire / polling brings to the table is worth it.

In closing #

I hope you enjoyed this dissection of our site list Livewire component. Other place in our UI, where realtime info is being displayed, was refactored in a similar fashion.

Working with Livewire was a pleasure. The API makes sense, the docs are well written, and it’s easy to create powerful components in a short amount of time.

If you want to see the Livewire components discussed in this blogpost in action, head over to Oh Dear and start your ten-day trial (no credit card needed).

After ten days, you might want to get a subscription. What sets Oh Dear apart from the competition is that we not only monitor your homepage, but your entire site. We can alert you when a broken link, or mixed content, is found on any pages of your website. And we also monitor certificate health and provide beautiful status pages like this one.

Should you have questions about these Livewire components, or Oh Dear in general, let me know in the comments below.

programming

via Laravel News Links https://ift.tt/2dvygAJ

April 16, 2020 at 09:06AM

9 Ledlenser Lights to Illuminate Your 2020

9 Ledlenser Lights to Illuminate Your 2020

https://ift.tt/2Vudln0

Whether it’s an everyday-carry pocket light, a stationary work light, or a fully featured flashlight for hunting and fishing, Ledlenser makes a product to meet your needs.

A field-worthy flashlight is one that can easily adjust from spotlighting the trail ahead to a strong, focused beam for locating the next cairn. Or maybe you’ll sleep better once you’re sure what you saw in the woods was just an odd-shaped tree.

Ledlenser lights have high-intensity LED beams, metal cases, and ergonomically designed features. Like knives and other outdoor essentials, you can find cheaper alternatives. But low-cost options often aren’t built with longevity in mind.

Flashlights, Headlamps, Lanterns, and More

These nine products exemplify the range of lighting options made by Ledlenser. And yes, the full line runs deep.

MH11 Performance Headlamp: $160

Ledlenser MH11 Headlamp

The flagship (and brightest) of Ledlenser’s headlamps, the MH11 was built to run 100 hours at 10 lumens, or switch over to Boost mode to light up surroundings at 1,000 lumens.

The companion Ledlenser Connect App lets you create and adjust the light to personalized settings within that range. In addition, there’s an RGB front light, a battery status indicator, and a magnetic charging cable.

We wrote about its best-selling predecessor, the MH10, here.

See the MH11 Performance Headlamp

K4R Keyring Flashlight: $25

K4R Keychain Light

Its slim aluminum case houses an LED that Ledlenser claims produces up to 60 lumens in a wide array. Smaller than most car key fobs, the light clips onto keys or bags with a metal snap hook and is rechargeable via USB.

See the K4R Keyring Flashlight

Torches (aka Flashlights)

T2QC Flashlight: $40

LEDLenser T2QC

A pocket-friendly flashlight for hunting, fishing, or camping, this “Quatro Color” torch can toggle between white, red, green, and blue for observing and tracking game.

See the T2QC Flashlight

P7R Flashlight: $90

Ledlenser P7R Flashlight

One of Ledlener’s best-sellers, the P7R showcases three power modes. The brand touts its ability to produce up to 1,000 lumens at 688 feet or be turned down to act as a floodlight. And the P7R uses a “floating” magnetic charging station (it doesn’t plug or clip in) designed for quick-grab use.

See the P7R Flashlight

EX7 Safe Flashlight: $88

EX7 Intrinsically Safe Light

From the Intrinsically Safe line, the EX7 is designed for use in nearly any environment (Ex-Zone 0/20). The light’s oversized case shape and large magnetic switch aim to facilitate easier handling and operation while wearing safety equipment.

See the EX7 Safe Flashlight

MT14 Flashlight: $100

Ledlenser MT14 flashlight

According to Ledlenser, the MT14 includes multiple technologies, like an adjustable ray that transitions from ambient floodlight to concentrated, long-distance beam. In all, it has four light functions for different outdoor scenarios.

One more feature the brand touts is a battery status indicator on the switch that serves as a visible reminder of when it’s time to recharge via its USB 3.0 port.

See the MT14 Flashlight

Lanterns and Area Lights

iF8R Area Light: $280

iF8R Area Light

The iF8R aims to provide a solution for lighting up a variety of spaces. Ledlenser promises a bright, consistent beam up to 4,500 lumens that can be controlled from a mobile phone while standing in the work area. The idea is to reduce the number of trips up and down a ladder.

Ledlenser designed the iF8R with a cooling system to keep it running for hours without overheating. The iF8R’s adjustable base has a built-in magnet for fastening it to metal surfaces and providing adjustability to angle the light just so.

See the iF8R Area Light

ML6 Lantern: $80

Ledlenser ML6 light charging phone
The Ledlenser ML6 camp light can also be used to charge accessories via a USB port

Designed to deliver glare-free LED to light up a campsite with 750 lumens, the ML6 Lantern has an oversized handle shape for carrying by hand or hanging from oversized branches. The ML6 also doubles as a power bank to recharge other electronics (via micro-USB).

See the ML6 Lantern

ML4 Mini-Lantern: $50

Ledlenser ML4 Charging

The ML4 is a 2.5-ounce lantern built to fit in a palm. The brand claims its latest micro-prism technology is powerful enough to provide glare-free light up to 300 lumens. And it achieves that with just nine LEDs.

Campers, take note: It measures less than 4 inches, comes with a red-light lens, and can run on AA batteries between charges.

See the ML4 Mini-Lantern


This article is sponsored by Ledlenser. You can learn more about the brand’s portable lighting options here.

The post 9 Ledlenser Lights to Illuminate Your 2020 appeared first on GearJunkie.

Outdoors

via GearJunkie https://gearjunkie.com

April 16, 2020 at 10:13AM

Nite Ize Rechargeable Glow Stick

Nite Ize Rechargeable Glow Stick

https://ift.tt/34IaBqn

Nite Ize Rechargeable Glow Stick

 | Buy

Glow sticks can add a splash of color and light to nighttime festivities. But they’re also filled with hazardous chemicals and only last a short time. Nite Ize’s version uses LEDs instead, and lasts for up to 8.5h per charge. It offers multiple colors to choose from, is IPX7-rated waterproof, and includes an S-biner clip for attachment.

fun

via The Awesomer https://theawesomer.com

April 16, 2020 at 10:15AM

5 Tips and Tricks to Start an Ecommerce Business in Your 40s

5 Tips and Tricks to Start an Ecommerce Business in Your 40s

https://ift.tt/2K73Ep8

Photo by Elena Koycheva on Unsplash

With no signs of the COVID-19 pandemic slowing anytime soon, more and more Americans are finding themselves unemployed. These economically tragic times are anxiety-filled for those in their 40s. They are back on the career hunt with fierce competition in the millions. So starting an ecommerce business in your 40s may not be a bad idea right now.

The ecommerce industry has taken a few hits during the coronavirus pandemic. However, if you are serious about getting into ecommerce, have a viable niche, and employ essential ecommerce solutions, you could achieve success.

Success right now may be a bit different in the beginning, though. You might not make what you were making while climbing the corporate ladder. However, you could make enough money to cover your bills and save a bit of cash. Keep in mind, though, that success will not come overnight. So be ready to roll your sleeves up and get to work.

To help, we compiled a few tips and tricks to start an ecommerce business in your 40s. Let’s dive in!

1. Niche Down for Quick Growth

Due to the competitiveness in the ecommerce industry, it is essential to find a micro-niche, especially if you’re starting out in your 40s. For instance, selling baby clothes online is way too broad. You will have a difficult time ranking in search engines for just baby clothes. Instead, niche down as far as you can go.

Here are a few questions to ask yourself when finding a micro-niche in the baby clothes segment:

  • What age group will be my demographic?
  • What will my price points be?
  • Will I sell boys’ and/or girls’ clothing?
  • What buyer persona is my target (mom, dad, grandparents, etc.)?
  • What is my unique selling point (differentiator)?

Find the micro-niche in the wider segment to grow faster. Your aim should be those first 1,000 followers and consumers.

2. Collaborate with Micro-Influencers

Since you are niching down as far as possible to achieve fast growth, consider collaborating with micro-influencers in your micro-niche. Why build your own audience base when you can tap into the loyal audience of a micro-influencer? This is a powerful tip when it comes to starting an ecommerce business in your 40s.

RELATED ARTICLE: TAP INTO THE POWER OF MICRO-INFLUENCERS AND WIN

For example, let’s say you have $1,000 to dump into a marketing strategy. You could go the traditional route and pay for Facebook and Instagram ads. But how confident are you in doing this on your own? It might be better to pay an influencer in your micro-niche to raise brand awareness for your online store.

This strategy allows you to reach 5,000 people who are already interested in the products you are selling online. Fast growth and sales are the aim here.

3. Test Your Market Viability Before Investing Too Much Money

One of the biggest mistakes new ecommerce business owners make is going all-in before testing the market. Did you know that the number-one reason startups fail is because there is little to no market for what they’re selling? This means testing the market is a must-do right from the start.

To test your market, set up a simple website using Shopify. A simple ecommerce website with SEO at the forefront will show you how much interest you have over a specific time period. Having this data and the projections it will give you will allow you to get a clear picture of the market.

4. Don’t Ignore Amazon or eBay

This is a very important tip to start an ecommerce business in your 40s. Did you know that many ecommerce businesses that sell on their own online marketplace also sell on Amazon and/or eBay? The reason behind this is consumer trust. Consumers know Amazon. This means they are more willing to buy on Amazon instead of a site they have never heard of.

However, there is a bit of work to setting up an Amazon and/or eBay seller account. You will need to meet the seller requirements for each platform. Amazon is a bit more challenging to get on than eBay. Here’s how to start selling on Amazon.

5. Buy an Ecommerce Business and Skip Early-Stage Issues—Because, After All, You’re in Your 40s

Another way to start an ecommerce business in your 40s is to not start one at all. Instead, buy an already-viable ecommerce business online using sites like Flippa. Going this route can save you a lot of the time and energy it would take to set up a brand new business.

The only downside to this is money. The price tag of an ecommerce platform that will net quick return on your investment ranges from $5,000 to $15,000. Therefore, be sure to do your due diligence when buying an existing business.

So Go Ahead and Start an Ecommerce Business in Your 40s

The above tips and tricks to start an ecommerce business in your 40s are among the most important. From testing your market with basic online tactics to buying an existing ecommerce platform, there is certainly a lot to consider. But if you are looking for an industry that allows you to make money on your terms, ecommerce may be an option.

The post 5 Tips and Tricks to Start an Ecommerce Business in Your 40s appeared first on Business Opportunities.

business

via Business Opportunities Weblog https://ift.tt/2CJxLjg

April 15, 2020 at 07:53PM

Arkham Asylum Releases All Inmates Amid Coronavirus Fears

Arkham Asylum Releases All Inmates Amid Coronavirus Fears

https://ift.tt/2XG2gSy

GOTHAM—Arkham Asylum has freed all its inmates to prevent the spread of coronavirus, sources with the Gotham Police Department confirmed earlier this week.

The prisoners were at risk for contracting COVID-19 and so were let go to take some of the strain off the Gotham prison system. After freeing them, interestingly, there was a rise in crime, a side effect the Gotham P.D. claim they didn’t see coming.

“Yeah, in hindsight, maybe this wasn’t the greatest idea,” said Commissioner Jim Gordon as a giant vine burst out of the ground and began wreaking havoc downtown and Bane punched walls just for fun. “Letting criminals out can sometimes cause a rise in crime, and we didn’t exactly see that coming.”

“HahahahahahahaHAHAHA!!!” cackled the Joker as he was let out. “Now it’s time to kill the Batman!” Medical officials believe killing the Batman could actually help further coronavirus outbreaks from occurring and so will turn a blind eye to the Joker’s evil plan this time.

Within two days of being let out, they were all caught again by Batman but then broke out again, before being caught again and then breaking out again.

“Yeah, we’re not great at this whole ‘running a prison’ thing,” said the warden.

Breaking: Paypal Now Available

Many of you told us you wouldn’t subscribe until we offered Paypal as a payment option. You apparently weren’t bluffing, so we finally caved and added Paypal. Now — like the unbeliever faced with God’s invisible qualities displayed in nature — you are without excuse.

fun

via The Babylon Bee https://babylonbee.com

April 15, 2020 at 06:03PM

What’s the Best Way to Enable (And Test) Encryption at Rest in RDS?

What’s the Best Way to Enable (And Test) Encryption at Rest in RDS?

https://ift.tt/2wFHcQX

Encryption at Rest in Amazon RDSThe other day on a call, a client asked me an interesting question.  We were discussing some testing they were doing in Amazon Relational Database Service (RDS).  The question came up “since RDS is managed, how can I prove to my security team that the data is actually encrypted?”  We’ve all read whitepapers and blogs that talk about encryption in the cloud, but it is something I’ve not needed to validate before.  Instead, I just enable encryption when I create an RDS instance and move along to the next steps of the setup. This discussion really got me thinking – what is the best way to enable and test encryption at rest in my RDS instance?

Encryption at Rest – MySQL Fundamentals

Before getting too far into the RDS specifics, I wanted to cover the basics of encryption at rest in MySQL.  There are essentially two ways to encrypt data at rest:

  • Full disk encryption (filesystem/block level)
  • Transparent Data Encryption (TDE) with InnoDB

Full disk encryption is just like it sounds – the entire disk (or data directory mount point) is encrypted and a key is needed to read the data.  Without this key, MySQL cannot read the data files and is rendered useless. This is a very straightforward way to maintain a flexible encryption setup as you can switch out storage engines or database servers altogether.

Transparent Data Encryption (TDE) was introduced in MySQL 5.7 and handles encryption at the instance level as opposed to the OS level.  By enabling a master key (using the keyring_file plugin or a remote service such as Vault), the InnoDB engine will encrypt its own data to disk.  Without access to the key, InnoDB will fail to load within MySQL. Likewise, any file-level backups (i.e. using Percona XtraBackup) will be rendered useless without the key.

Both methods are completely acceptable forms of encryption at rest, but different organizations may choose one or the other based on their specific requirements.  When looking at RDS, however, things are different.

Encryption at Rest – RDS

As RDS is a managed service, you do not interact with the base operating system or filesystem.  Rather, you leverage the API provided by AWS to launch and configure your instance. This poses a problem if you are currently using a keyring_* plugin in MySQL – how do you store your master key on the filesystem or configure other plugins for remote key management?  Unfortunately, you can’t. However, there is still a viable solution for encrypting your data at rest with RDS.

With RDS being built on the underlying IaaS components of AWS, you are able to leverage the existing functionality of those components through the API.  The feature we are looking at here is EBS (Elastic Block Store) encryption. Much like the full disk encryption method described above, EBS allows you to encrypt volumes using AWS default keys or customer master keys (CMKs) defined within the Key Management Service (KMS).  These keys are required for the volume to be usable and for snapshots to be restorable. This enables you to ensure data-at-rest encryption for your RDS instances.

Putting it All Together

In the past, I’ve used both the RDS default encryption key and user-defined keys.  For this exercise, however, I wanted to ensure I could prevent my database from being restored or restarted on demand.   To start, I created a new CMK in the KMS service to use with my database and gave the RDS service permission to access it:

Then, when I create my RDS instance, I can choose this new key when I enable encryption.  For my test, I encrypted my instance using a cleverly named CMK key called database-key:

Note that along with my CMK, the (default) aws/rds key is an option.  I want control over my key and when it is used so I choose my key and not the default.  Note that certain instance types don’t offer encryption so if you don’t see this option when creating your instance, check your instance type against the list here.

After that, it is just business as usual.  I connected to my RDS instance, populated some dummy data, and took my first snapshot.  This is when it was time to confirm that I could indeed disable the key and prevent access to my data.  Here is the important thing to note – as my instance was encrypted with a specific key at startup, the snapshots also require the same key.  You can see that in my Snapshot Restore window, it specifies the key needed and I don’t have the option to disable it or choose another key:

This is how RDS ensures that the key is tied to the instance and you can’t just take the data and restore it elsewhere.  After disabling my CMK (with my instance still running), I tried to restore my snapshot. Success! My snapshot was not able to be restored and I was pleasantly greeted with the following error message:

This confirms that by using my own key, I can effectively lock out any unauthorized restoration or access to the data at the disk level.  But now, I wanted to verify one additional item. Looking at how encryption at rest works on a standard instance, I also wanted to confirm that the key was needed to start the instance.

With the key disabled, I stopped the running instance.  After that process completed, I tried to restart my instance.  Again, it was successful in that I was not able to restart my instance with the key disabled:

So just like a standard instance that is missing the master key, the RDS instance isn’t able to start with the key disabled.  Similar to an on-prem deployment, ensuring that your CMK is secure is outside of the scope of this blog post. But with that being said, this exercise demonstrates the power and flexibility of using CMKs to ensure your data is encrypted at rest.

Wrapping Up

Hopefully, this post and example were useful to you.  It is always a good practice to ensure that documentation matches behavior.  In this case, I feel confident that leveraging CMKs to control my RDS encryption should meet a majority of security requirements.  For any help ensuring that your RDS deployment is following best practices, please don’t hesitate to reach out to Percona. We’d be happy to help ensure your RDS (or other cloud) deployment is done in the best possible way!

technology

via MySQL Performance Blog https://ift.tt/1znEN8i

April 15, 2020 at 02:01PM

WATCH: Rifle Training, Skills and Safety for First-Time Buyers

WATCH: Rifle Training, Skills and Safety for First-Time Buyers

https://ift.tt/2xuRpA4

As the COVID-19 global pandemic continues to spread, more and more Americans are purchasing guns for their protection. After runs on food and goods sparked into panic buying, guns and ammo sales reached record highs. Americans have spoken, and they clearly want the right to buy guns to protect their family. In fact, many are buying guns for the very first time. With that in mind, we’ve put together a three-part introductory video series on handgun, rifle, and shotgun training, skills, and safety. Here’s the second video in our series, focusing on rifles. Be sure to check out “Part I: Handgun Training” and “Part III: Shotgun Training” as well.

The shotgun remains a formidable home defense weapon.

RELATED STORY

WATCH: Shotgun Training, Skills and Safety for First-Time Buyers

Rifle Training, Skills and Safety

Most importantly, all gun owners must follow the four basic gun safety rules: Treat every gun as if it were loaded. Never point a gun at anything you don’t want to destroy. Always keep your finger off the trigger until you’re ready to shoot. Know your target and what’s beyond it. Those four rules should define every choice you ever make in gun handling. Follow them, and you’ll never have a problem, a negligent discharge or worse.

The rifle, especially America’s most popular rifle, the AR-15, excels in the role of home and self-defense. With a 30-round magazine, extremely intuitive controls and high accuracy potential, most contemporary semi-automatic rifles are easily learned. You can often shoot them well, with an extremely fast learning curve.

However, there’s still much that must be learned, especially for the new shooter. Rifle manipulations, magazine changes, and shooting all require training and practice. While the AR design remains especially popular, it still brings its own set of challenges and requirements to run safely and effectively.

Finally, welcome to the 2A club. While it took a global pandemic for some to get here, we’ve all got one thing in common. We all decided to take full responsibility for our family’s ultimate safety and protection. Owning a firearm, especially a rifle, brings tremendous responsibility. So watch our video, learn, and then seek out certified training. Then get to the range and practice. Knowledge is power, so share it with any and all potential gun owners out there.

The post WATCH: Rifle Training, Skills and Safety for First-Time Buyers appeared first on Personal Defense World.

guns

via Personal Defense World https://ift.tt/2Arq2GB

April 15, 2020 at 12:18PM

WATCH: Handgun Training, Skills, and Safety for First-Time Buyers

WATCH: Handgun Training, Skills, and Safety for First-Time Buyers

https://ift.tt/2XEHiUe

The coronavirus pandemic changed the world. As shelter-in-place orders and shutdowns mirrored climbing cases and death counts, runs on goods such as food and supplies sparked even more fear about the coming days. We were entering extremely uncharted waters. In short order, many people turned to exercising their Second Amendment rights, some for the very first time. Since so many folks purchased their very first firearms for home defense, we’ve put together a three-part introductory video series on handgun, rifle, and shotgun training, skills, and safety. Here’s the first video in our series, focusing on handguns. Be sure to check out “Part II: Rifle Training and “Part III: Shotgun Training” as well.

Pistol Drawing, Josh Froelich teaches his preferred conceal carry drill on target transitions.

RELATED STORY

WATCH: Quick Pistol Drawing With Pro Shooter Josh Froelich

Handgun Training and Safety

First, right out of the gate, new gun owners, and old ones for that matter, must follow the four basic gun safety rules: Treat every gun as if it were loaded. Never point a gun at anything you don’t want to destroy. Always keep your finger off the trigger until you’re ready to shoot. Know your target and what’s beyond it. Those four rules should define every choice you ever make in gun handling. Follow them religiously, and you’ll never have a problem, a negligent discharge or worse.

Semi-automatic handguns remain an extremely popular choice for home and self-defense. Compact and concealable, handguns deliver tremendous versatility. But one must master the fundamentals of handling, loading and shooting a pistol. In fact, pistols are the toughest of the firearm platforms to shoot accurately, requiring the most training and practice.

So watch the video and learn. Then, as you can, find a qualified, certified instructor and get some training. Finally, invest in some ammo and hit the range to practice.

Welcome to the 2A gun club. We’re happy you’re with us. Now get trained up, and then pay it forward by taking someone you know out to the range for a day of shooting. Lastly, have fun and be safe.

The post WATCH: Handgun Training, Skills, and Safety for First-Time Buyers appeared first on Personal Defense World.

guns

via Personal Defense World https://ift.tt/2Arq2GB

April 15, 2020 at 12:18PM

WATCH: Shotgun Training, Skills and Safety for First-Time Buyers

WATCH: Shotgun Training, Skills and Safety for First-Time Buyers

https://ift.tt/3coyZjx

The coronavirus pandemic, and the ensuing panic, has changed the gun narrative in America. Now more than ever in recent memory, Americans are turning to the Second Amendment to ensure the safety of their families. Gun and ammo sales continue to soar; that means many first-time buyers are heading to gun stores. We want to make sure new gun owners have the proper training. So we’ve put together a three-part introductory video series on handgun, rifle, and shotgun training, skills, and safety. Here’s the third video in our series, focusing on shotguns. Be sure to check out “Part I: Handgun Training” and “Part II: Rifle Training”  as well.

Handgun Training, Pistol Training, Handguns 101, Pistols 101, First-time buyers

RELATED STORY

WATCH: Handgun Training, Skills, and Safety for First-Time Buyers

Shotgun Training, Skills and Safety

First and foremost, all gun owners must follow the four basic gun safety rules: Treat every gun as if it were loaded. Never point a gun at anything you don’t want to destroy. Always keep your finger off the trigger until you’re ready to shoot. Know your target and what’s beyond it. Those four rules should define every choice you ever make in gun handling. Follow them religiously, and you’ll never have a problem, a negligent discharge or worse.

The shotgun remains one of the most effective tools for home defense. Users can load low-brass birdshot to ensure rounds don’t over-penetrate interior walls. For more firepower, buckshot also becomes a formidable stopper. And when you really have to take down something big or engage targets at range, slugs prove devastating.

But there is much to learn to effectively manipulate, run and fire a shotgun in a defensive setting. Watch our video, learn, and then invest in some quality, certified instruction. Then get on the range and practice, practice, practice. Shotgun loading takes time to master, and you can never be proficient enough running a defensive shotgun.

Welcome to the firearms community. Get trained, practiced hard, and have fun out there on the rang. And remember, share what you’ve learned with others.

The post WATCH: Shotgun Training, Skills and Safety for First-Time Buyers appeared first on Personal Defense World.

guns

via Personal Defense World https://ift.tt/2Arq2GB

April 15, 2020 at 12:18PM

Everything You Need to Know About the GLOCK 19

Everything You Need to Know About the GLOCK 19

https://ift.tt/3ccyRn4

Ah, the unfailing GLOCK 19. Have you ever wondered about the story behind one of the world’s most popular pistols? What it would be like to fire an excellently crafted handgun built to withstand any conditions for home defenders, servicemen and women alike?

How about some points on maintaining an efficiently built weapon like the GLOCK 19? We’ll take a shot at all of these topics and more below. Let’s dive right in.

GLOCK 19 History

There are five generations of this famous pistol, but we will begin with the story of the GLOCK company to really understand where our latest G19 comes from.

Gaston Glock, an Austrian engineer, began his humble career in the glamorous realm of curtain rod manufacturing in the 1960s. Weird, right? Not what I think of when I picture the deadly accurate pistols that bear his name!

Anyway, in the 70s, the Austrian military commissioned him to design knives, grenade casings and machine-gun belt links. Thus began his entry into the firearms business.

Gaston Glock designed his first handgun in 1981 at the request of the military, which needed an accurate gun that could be fired quickly in the field of battle.

Already an expert in polymer manufacturing, Glock took to his garage workshop and designed the first-generation G17.

It took about 18 months for him to fine-tune his renowned SAFE ACTION system that eliminates the need for an external safety by incorporating a tri-tiered safety system using the trigger, firing pin and drop safety.

The first G19 was designed in 1988, and was built with fewer parts to minimize the chance of malfunctions. He built his name and company on the word reliability.

As the GLOCK handguns became more popular, especially for police and military forces, more problems with his design became apparent.

Most famously, the “AD Heard Round the World” incident occurred in 1992 when a New York officer’s weapon discharged multiple times with his hand nowhere near the trigger.

After this incident, GLOCK changed their tooling methods and over the subsequent years honed the G19, with upgrades to every new generation, into one of the most reliable handguns on the market today.

GLOCK 19 and GLOCK 17 on Stack of Bullets
From @thattexasguy762 on Instagram

GLOCK 19 Specs and Performance

I’ve used the word “reliable” several times already, but I want to break down exactly why I’m using that term so freely with the G19. With more than 60,000 9mm rounds through the action, this handgun has had ZERO malfunctions for me. Zero.

It is so efficiently designed that the G19 is capable of withstanding the most brutal conditions. It is not a classically pretty gun, but, boy, will it do its job.

As far as accuracy goes, the G19 will hit its mark whether you are using it for competition, as a duty gun or for concealed carry defense. At 25 yards, it was averaging 3-inch 5-shot patterns.

The Marksman barrel has hardline rifling that stabilizes shots, while the balance and dual recoil spring assembly create minimal kick so you are able to lock back on target quickly with precision.

Ergonomically, the G19 feels good to shoot. The Gen5 has removed the annoying finger grooves found in Gen3 and Gen4, and the customizable backstraps give you the grip size you want.

One thing that I personally would modify, however, is the awkward, angular trigger guard and uncomfortable cutout in the front of the magazine well.

These are minor annoyances, however, and are totally based off of personal preference.

Overall, the G19 is comfortable, soft-shooting and well-balanced. Here are some specs:

  • Caliber: 9x19mm
  • Capacity: 15 + 1
  • Trigger: 5.5 lb. pull
  • Dimensions:
    • OAL: 7.28”
    • Height: 4.99”
    • Width: 1.18”
    • Weight: 23.65 oz

The GLOCK 19 is reasonably priced, retailing around $600 (or $699.99 if you upgrade the standard polymer U-dot sights to AmeriGlo Night Sights).

The popularity of this pistol makes it easy to find in most outdoor stores, but can also be found online and at specialty shops.

GLOCK Maintenance

Before you get started cleaning your new G19, you’ll want to disassemble it properly according to the owner’s manual.

Here’s a brief summary of what that looks like…

Disassembly

As with any weapon, before you do anything, be sure to remove the magazine and check that the chamber is empty, both by looking and feeling inside the chamber. Remember to always have the weapon pointed in a safe direction.

Once you’ve done that, here are some steps for disassembly:

  • Remove slide. With the slide pulled back about a quarter of an inch, remove the slide by pulling the disassembly tabs down and moving the slide forward.
  • Take out the recoil spring assembly and then the barrel.
  • Disassemble the slide assembly. With the GLOCK armorer’s tool, push the firing pin spacer sleeve down and take the slide cover plate off with your thumb.
  • Remove the firing pin assembly and extractor depressor plunger. Push down on firing pin safety to remove the extractor last.
  • Disassemble the receiver. First take out the locking block pin from either direction. Move the slide stop lever back and forth while using the armorer’s tool to push on the trigger pin until the trigger pin is released.
  • Remove the trigger pin. Then, lift out the slide stop lever and pry the locking block out. Push on the trigger housing pin on the backstrap and pull out the trigger mechanism.

After disassembling and cleaning your weapon, reassembly is just these steps in the reverse order (with the exception that the locking block pin should always be the first pin to go back into the receiver).

Cleaning

When cleaning your GLOCK, make sure you use good-quality gun lubricant and the tools supplied with your weapon.

You’ll need cloth patches, a brass bore brush, the GLOCK cleaning rod that came with your weapon, gun lubricant of your choice, a dual-end cleaning toothbrush, Q-tips, clean rags, cleaning solvent and a clean, flat area to work in.

Got it? Good. Here are some steps for cleaning:

  • Clean your barrel. With a solvent-dampened patch attached to your cleaning rod, sweep out the chamber several times in a clockwise rotation starting with the breech end.
    • Then, do the same thing with a brass bore brush until the chamber looks shiny and clean. Scrub carbon deposits off of the exterior portions of the barrel using a cleaning toothbrush and solvent.
    • Wipe off with a rag and make sure the bore is dry by using a dry patch.
  • Clean your slide assembly. Use the cleaning brush to clean the breech face and in and around the extractor. DO NOT get solvent in the firing pin channel.
    • Take a clean Q-tip and sweep out the slide rail cuts as well as the inside of the slide. A wet patch can be used to clean the underside and inside of the slide. Use a dry patch to wipe everything clean.
  • Clean your receiver. Remove carbon deposits from the contact points and locking block using the toothbrush. Brush debris from inside of the receiver.
    • With a clean rag, wipe clean the ejector, cruciform, trigger bar, connector and locking block.
  • Lubricate your weapon. Apply one drop to the outside front barrel and one to the rear barrel lug. Holding the frame left side down, apply one drop to the connector.
    • For the slide, face the rail cuts upward and drag one drop-down each cut. Then, add one drop to the top of the slide where it rubs the upper barrel and you’ve got a clean weapon.
GLOCK 19 with Knife
From @balistix_4o6 on Instagram

Conclusion

For many law enforcement agencies and home defenders alike, the GLOCK 19 is the favored choice because of its reliability, ease of care, competitive price and well-balanced shootability.

To recap, the GLOCK 19 is:

  • Durable
  • Easy to maintain
  • Practical for many situations
  • Highly accurate (3-inch patterns)

Overall, GLOCK has really delivered with their latest generation of G19s. There’s a reason the GLOCK 19 is one of the most popular weapons on the market, and now you have everything you need to know to check it out for yourself.

What are your thoughts on the GLOCK 19? Let us know by leaving a comment below.

Get the Best Deals on Guns, Ammo & Gear sent 3 days a week.

guns

via The Shooter’s Log https://ift.tt/2VbyLGM

April 15, 2020 at 08:38AM