Fast and efficient data serialisation with Protocol buffers (protobuf) in .NET

  Рет қаралды 24,245

Nick Chapsas

Nick Chapsas

Күн бұрын

Subscribe: bit.ly/ChapsasSub
Become a Patreon and get source code access: / nickchapsas
Hello everybody I'm Nick and in this video I will show you what are the advantages of using Protocol buffer (or protobuf) in order to serialize and deserialize your data in .NET. Not only you will be able to run faster operations because of it but you will also be able to store a significantly smaller object while gaining performance. In this video I will use Redis as an example of a use case.
Don't forget to comment, like and subscribe :)
Social Media:
Follow me on GitHub: bit.ly/ChapsasG...
Follow me on Twitter: bit.ly/ChapsasT...
Connect on LinkedIn: bit.ly/ChapsasL...
#dotnet #csharp #protobuf

Пікірлер: 29
@AlexMescalinich
@AlexMescalinich 3 жыл бұрын
Moving our internal microservices call to gRPC, speed matters! Thanx for Redis case, that's a great improvement also!
@markpolak8317
@markpolak8317 Жыл бұрын
Hi Nick, I know this is an older video, but could you maybe try out different data serialization libraries, compare them and share you insight about them. Json, MessagePack, protobuf and MemoryPack?
@malcolmlearner
@malcolmlearner 3 жыл бұрын
You mentioned a docker-compose you were going to add to the description, but I'm not seeing it. It IS a helpful video!
@alfredoquintanalopez2265
@alfredoquintanalopez2265 3 жыл бұрын
It's a great video and a great use case of proto serialization, really out of the box, it open my mind for a lot places where I can use it. Thanks a lot!!!!!
@DryBones111
@DryBones111 2 жыл бұрын
The memory gains in the Redis cache are a great benefit, but if the aim was optimising response time would it make more sense to cache the response body verbatim? I.e. if the response body was the json string then if you had a cache hit, you wouldn't even need to deserialize (and then serialize into your dto again) as you can just pass on the cached value instead (which is already a json string of your dto).
@kevinli9212
@kevinli9212 3 жыл бұрын
Fantastic video, you are very good at explaining things in plain English.
@chintsbilly
@chintsbilly 3 жыл бұрын
Thanks Nick for sharing with us. You are saviour. God bless you ❤️.
@DanteDeRuwe
@DanteDeRuwe 3 жыл бұрын
Really want to see grpc video! Protobuf looks very efficient too
@killpopers
@killpopers 3 жыл бұрын
Very good technology ill have to take a look. how does it handle adding a new property to the contract?
@faisalmorensya4936
@faisalmorensya4936 3 жыл бұрын
awesome man, thanks for on point explanation
@artbiel228
@artbiel228 3 жыл бұрын
Thanks a lot! Very useful video!
@HiImKyle
@HiImKyle 3 жыл бұрын
Is there any way to automatically create contracts without all the messing around with the attributes..? I'd rather just use JSON at this point, less stuff to get it to work
@vankhanhnguyen2514
@vankhanhnguyen2514 2 жыл бұрын
Hi, How to use buffers ring in microservices with ocelot?. Lookl forward to avideos.
@randompoints
@randompoints 3 жыл бұрын
What do think using protobuf to pull tracking history which is in our case about 2MB atleast ..takes about 15 sec?is this production stable? I'm thinking of trying it.
@acidrazor
@acidrazor 3 жыл бұрын
you scratched the surface, now theres an itch, need more input!! :P
@soho1080
@soho1080 3 жыл бұрын
Ok.. So basically this is only to demo the local serialiazation/deserialization for your in mem cache right? Coz i see youre still sending the json format over the wire! if so then where's the real benefit of using protobuf in the first place.
@nickchapsas
@nickchapsas 3 жыл бұрын
The benefit is that Redis will store less data which means that more data can be cached and the data will be deserialized and serialized faster and with less memory from and to Redis. The only place where JSON is returned is on the API layer, but that's the other end of the app and it's irrelevant to this demo. If you want protobuf based responses you'd need to implement the same serializer for the API layer and expose it using the application/protobuf content type, but at that point you might as well migrate to gRPC. Btw in case it wasn't clear, protobuf is sent over the wire to Redis. It's not an in-process cache.
@soho1080
@soho1080 3 жыл бұрын
@@nickchapsas Yep I got that one. Just making sure the wire activity is still on the json format. Thanks man! Good demo.
@moneymaster5571
@moneymaster5571 3 жыл бұрын
Hey Nick, Great Video thanks a lot for posting. One question for you. can we use protobuf to do serialization and deserialization for the rest calls ? Like I wanted to communicate between my angular app and aspcore api with protobuf instead of JSON objects. Please advice
@nickchapsas
@nickchapsas 3 жыл бұрын
You actually can. There is also a nuget package that adds a header that you can use to enable it. The problem is that the recipient needs to be aware of the protobuf contract. If you get to this point then you might as well use gRPC
@lkarabeg
@lkarabeg 3 жыл бұрын
Protocol buffers don't allow types to be nullable, which is a huge drawback for this use case.
@nickchapsas
@nickchapsas 3 жыл бұрын
First, not supporting null is a benefit not a drawback. Besides that, you can use "optional" if some value can be null.
@lkarabeg
@lkarabeg 3 жыл бұрын
Oh, hi, Nick! Thanks for sharing all the great content you do. I disagree on this one, though. The optional keyword doesn't let the value be "unset". So if your JSON schema has optional fields, your protocol buffer can't represent that schema without adding boolean fields and mapping logic. And in general, once you pollute the data with default values, you can't change the default any more. Nulls serve a real need in that regard.
@nickchapsas
@nickchapsas 3 жыл бұрын
@@lkarabeg If your contract is so fluid that it can have so many nullable values then you probably have to look into that first.
@SecondFinale
@SecondFinale Жыл бұрын
What is it? "A language-neutral, platform neutral, extensible mechanism for serializing structure data". No, what is it really? "A good binary serializer". I don't think they describe it well for adoption.
@semen083
@semen083 2 жыл бұрын
It is protobuf make more memory allocation cause intensive MemoryStream usage?
Creating custom dependency scopes in .NET
13:29
Nick Chapsas
Рет қаралды 13 М.
What is Span in C# and why you should be using it
15:15
Nick Chapsas
Рет қаралды 256 М.
ДЕНЬ УЧИТЕЛЯ В ШКОЛЕ
01:00
SIDELNIKOVVV
Рет қаралды 3,3 МЛН
Do you choose Inside Out 2 or The Amazing World of Gumball? 🤔
00:19
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17
Inside Out 2: ENVY & DISGUST STOLE JOY's DRINKS!!
00:32
AnythingAlexia
Рет қаралды 15 МЛН
Protocol Buffers Crash Course
36:07
Hussein Nasser
Рет қаралды 247 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 259 М.
The Logging Everyone Should Be Using in .NET
15:34
Nick Chapsas
Рет қаралды 72 М.
Intro to In-Memory Caching in C#
33:56
IAmTimCorey
Рет қаралды 80 М.
Don't Use Polly in .NET Directly. Use this instead!
14:58
Nick Chapsas
Рет қаралды 64 М.
Testing in .NET is About to Change
12:54
Nick Chapsas
Рет қаралды 69 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 361 М.
Mapster, the best .NET mapper that you are (probably) not using
24:02
Stop Using FirstOrDefault in .NET! | Code Cop #021
12:54
Nick Chapsas
Рет қаралды 79 М.
Build Clean Messaging in .NET with MassTransit
21:44
Nick Chapsas
Рет қаралды 99 М.
ДЕНЬ УЧИТЕЛЯ В ШКОЛЕ
01:00
SIDELNIKOVVV
Рет қаралды 3,3 МЛН