abpframework / abp

Open Source Web Application Framework for ASP.NET Core. Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET and the ASP.NET Core platforms. Provides the fundamental infrastructure, production-ready startup templates, application modules, UI themes, tooling, guides and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.31k stars 3.32k forks source link

Why and when we must use (install) redis ? #3487

Closed sebitsi closed 3 years ago

sebitsi commented 4 years ago

Hi.

In documentation Redis is noted as pre-requirement.

If we use identity server included inside httpapihost project redis is not needed. If indentity server is in separate service, we must install redis. Is this correct ?

Why is that ? Can you explain a little more. Can we avoid to install redis ?

As ABP Framework is .NET core based, it is cross platform deployable. Redis is linux. Right ? This is not convenient for windows "users" as myself. Can you give us some support/docks/links about redis. I mean - some links to docs about how to ?

Please don't give me link to redis official site. There is a lot of informations. For begginer like me, i don't know where to start.

Thanks for advance.

Edvin

hitaspdotnet commented 4 years ago

https://redislabs.com/blog/redis-on-windows-10/

gdlcf88 commented 4 years ago

If indentity server is in separate service, we must install redis. Is this correct ?

Yes, redis can help to share data between IDS4 and your host.

sebitsi commented 4 years ago

@hitaspdotnet and @gdlcf88 Thanks for answeres.

Yes, redis can help to share data between IDS4 and your host.

How is this "sharing" related to ABP or maybe ASP.NET Core ? I mean, is this ABP or ASP.NET core feature ?

Is this redis cache basicaly very fast service for setting and getting key-value pairs ?

gdlcf88 commented 4 years ago

I don't know more, maybe you can start looking for answers here: https://github.com/abpframework/abp/issues/2224#issuecomment-557024682

sebitsi commented 4 years ago

Thanks @gdlcf88. There is no much info on this question.

I hope @hikalkan can write some documentation what is important when using ABP with redis. Or point me to one if there is any.

sebitsi commented 4 years ago

I found ASP core documentation about implementing redis cache.

There is a link to chocolately windows instalation which is 4 years old.

What version do you recoment using on windows ?

sebitsi commented 4 years ago

What about Memurai. Do you have experience with it ?

leonkosak commented 4 years ago

@sebitsi Redis is also important if you have clustered environment and you use SignalR (since SignalR Core have currently no backplane option for MSSQL).

sebitsi commented 4 years ago

Thanks @leonkosak.

For start i just want to collect needed data for implementing identity server as standalone service. SignalR is not in first plan. Luckily. ;)

I'm preparing to upgrade my zero projects to abp.io. It is not so easy as i expect.

It's not only about code. We must look ahead what we can and can not do in production environment.

So any additonal info is desirable.

gterdem commented 4 years ago

Hello @sebitsi, Redis is volatile but can be persistent on disk to prevent data loss. Meaning; in-memory db, stored in RAM hence very very fast.

It is used for caching purpose mostly. You don't need an extra server in monolithic apps since you can use in-memory cache already which lives in your application life cycle (memcache).

But in distributed systems when you need to cache some data instead of making thousands of http requests, you need an extra server for that.

One of the use cases in ABP is for caching permissions where you need to check if the requesting token (user) has the permission of the requested resource.

I see you hate installing extra stuff to your windows like me :) Use docker for windows! Works like a charm.

Afterwards you only need to run the command docker run --nameredis-container -p 6379:6379 -d redis and change the redis connection string in your appsettings to localhost:6379.

Not to mention you can use mongodb, postgres etc on containers without installing aswell.

Hope this info helps.

sebitsi commented 4 years ago

@gterdem Thanks for your explanation and clarification. Yes it helps.

You put together all my knowledge and confirm it. ;)

Of course, I could use docker for installing redis. But i have limitations on production server. This is first point. Second is: I need to monitoring it, updating it. So mantaining it. ;(

Some more questions:

  1. You wrote that redis is used for caching permissions ....

Identity server is central point for checking credetials, generating tokenc, etc. Right ? It wouldn't by nice if identity server has a cache for caching all that requests ? Yes maybe this is not good enought for extra large systems. But for small to middle.. ? It Will bi simpler to deploy, maintain and less compex.

  1. How redis fits in permission checkig flow ? I mean: who store permissions into redis ? Identity server or micro service ? How long this key stays in cache ?

  2. Have you some information about redis integration implementation in code ? I mean: Is this bassicaly ASP.NET Core code extendet with ABP or pure ABP ?

Thanks for advance.

Edvin

dicksonkimeu commented 4 years ago

I advice you create normal asp.net core website do tests on redis and once you make a decision to use redis, you can enable it.

Otherwise you can disable it in abp, its and optional. Sounds like you want someone to prove to you why use redis yet its optional and depends with what you are doing in your project.

sebitsi commented 4 years ago

@dicksonkimeu

I want to use indetity service as separate service. I just want to get big picture how redis is integrated into ABP. How and when should i use it. I need to advice admins on customer's production environment why we need redis, how to configure and maintain it, etc

In ABP docs there is only one sentence. Redis is required. And this is it.

I hope, guys in ABP are goint to make some docs about it.

dicksonkimeu commented 4 years ago

Its not how redis is integrated to ABP. Nothing special on ABP. Its about redis and asp.net core.

Create a asp.net core project (without abp) and test how redis works.

sebitsi commented 4 years ago

@dicksonkimeu

Ok. Thanks. I know nothing about redis. Where i can start ? What do you suggest ?

Nothing special on ABP.

Maybe. But they create template which requires redis. So i expect they explain how they use it and why.

dicksonkimeu commented 4 years ago

start at google

https://dotnetcoretutorials.com/2017/01/06/using-redis-cache-net-core/

danghung-dev commented 3 years ago

@gterdem Thanks for your explanation and clarification. Yes it helps.

You put together all my knowledge and confirm it. ;)

Of course, I could use docker for installing redis. But i have limitations on production server. This is first point. Second is: I need to monitoring it, updating it. So mantaining it. ;(

Some more questions:

  1. You wrote that redis is used for caching permissions ....

Identity server is central point for checking credetials, generating tokenc, etc. Right ? It wouldn't by nice if identity server has a cache for caching all that requests ? Yes maybe this is not good enought for extra large systems. But for small to middle.. ? It Will bi simpler to deploy, maintain and less compex.

  1. How redis fits in permission checkig flow ? I mean: who store permissions into redis ? Identity server or micro service ? How long this key stays in cache ?
  2. Have you some information about redis integration implementation in code ? I mean: Is this bassicaly ASP.NET Core code extendet with ABP or pure ABP ?

Thanks for advance.

Edvin

With signalR how can I use redis to share connection between multiple instance. I have read this document. But I don't know how to implement it with abp.io https://docs.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-3.1

I am very appreciate if someone explain them.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ebicoglu commented 5 months ago

What is Redis? Where is it being used?

Why must we use Redis in ABP projects?

You only need to install Redis for the n-tier architecture where Web and HTTP API layers are physically separated. If you work on an n-layered solution with no HTTP API project, then you don't need Redis. Getting started page

You can see in which cases Redis is pre-required from the documentation page: docs.abp.io/en/abp/latest/Getting-Started-Setup-Environment?UI=MVC&DB=EF&Tiered=Yes

What exactly is being cached in Redis?

Finally, I want you to know that you can replace Redis with any other caching provider like Memcached.

Resources:

hikalkan commented 5 months ago

Also see https://docs.abp.io/en/abp/latest/Deployment/Clustered-Environment#switching-to-a-distributed-cache

Basic answer: