Designing ServiceStack with RedisMQ - servicestack

I am implementing a solution that has a web interface (service stack) and a long running job service (servicestack?).
I already implemented the web interface and found servicestack a really good framework for creating what i wanted. I used redis as a semi reliable object store.
Then i started to think about how to implement the job service.
What i originally thought i do was to set up a simple windows service and have the redis client pick up thinks marked for the job service ( how exactly i wasn't sure ). These are very long running jobs that require alot of resources so i want to throttle how many of them are running at a time and also if i could fan out with worker machines that would be nice.
Then i saw that ServiceStack has a RedisMQ that might fit the bill, and hence the question.
Should i create a seperate servicestack service and host it in a windows service. Then have a MQ interface on it and let the webservice post to that message queue jobs that need to run. Then the jobservice is decoulpled from the webservice and all is well.
or
Am i over thinking it and should just use the logic part of the service i already have running and implement the job logic there, could pop in a MQ but in the same process that would probably just be a waste of time. I could skip the message part entirely and just call the logic part straight with some throttling algorithm.
Also when i was testing this out i had trouble with creating the RedisMQ server
using ServiceStack.redis;
using ServiceStack.messaging;
var mqHost = new RedisMqServer(redisFactory, retryCount:2);
Returns RedisMQServer not found.
I did a full nuget install of the servicestack and servicestack.redis packages
install-package servicestack
install-package servicestack.redis
When i use object browser on the .dll i don't find any mention of the ReidsMQServer, the version i 4.0.15
I found this url https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Server/Messaging/Redis/RedisMqServer.cs
And would think that this should belong to the servicestack.redis reference.
Any help appreciated,
cheers

Redis MQ is in the ServiceStack.Server NuGet package, i.e:
PM> Install-Package ServiceStack.Server
When in doubt as to which package to install, refer to ServiceStack's download page, e.g: https://servicestack.net/download#mq

Related

"Dependency hell" when using same npm module for both sdk and service itself

I'm currently developing a project in Node JS that uses microservices architecture, in which each service has it's own repository that contains both the code for the service itself (NodeJS express server), and also an SDK file that I publish for other services to use with methods that are available in this service and Typescript definitions.
So for instance I have a users-service that handles all of the user related actions, and a reports-service that handles all of the reports that users can CRUD.
users-service has a method called "deleteUser" that also goes to reports-service SDK in order to delete all of this user reports. On the other hand reports-service uses user-service SDK to "getUserById" for instance. So what happens is that user-service has reports-service-sdk as one of it's dependencies, and reports-service has users-service-sdk as one of its dependencies. Because the SDK is inside the same npm module with the service, I get users-service-sdk as one of the dependencies of users-service.
I thought of separating the SDK with a different package.json file, but I wanted to know if it's the right way to go or am I doing something really wrong in my architecture :)
Thanks.
This sounds like Circular Dependency which as you stated in the title is tough to deal with. Microservices are great but this sort of architecture sounds like a lot of extra unnecessary work without any added benefit.
You should look into running your services/packages/repositories as Cloud functions (or Firebase functions). AWS also has their own solution for microservices architecture. The reason being is each service can communicate with other services by using internal authorized calls or authorized REST API calls --- or you can make them totally public.
The great thing about these Google Cloud Functions is each function is automatically an Express end-point that accepts GET, POST, DELETE, PUT. Or if you use the internal call for Firebase, each function automatically contains relevant context from the frontend (such as the user's authentication details).
You also configure IAM permissions to only allow who and what service you want to be able to execute your cloud functions so that you have full control of permissions.
To answer your questions directly though, I would definitely avoid Package A having Package B as a dependency as Package B has Package A as a dependency. You absolutely can make that work but there's no upside and a lot of downside.
Here's an old thread which covers the topic.

Using Azure SDK for JS to create .NET 4.x App Service

I'm starting to wonder whether this is the right tool for the job, still here goes.
I'm attempting to automate the creation of our Azure Test environment using Azure SDK for JS. The environment spans many services (as you can imagine), including Classic ASP.NET app services.
Node is my safe space, so that is why I started with the JS SDK.
I have started scripting the creation of an app service using WebSiteManagementClient.webApps.createOrUpdate. I'm confused though, there is seemingly no way to configure any of the following:
Which app service plan the app service should be connected to. This feels fundamental.
The operating system, Windows or Linux.
The stack version, .NET 4.8, .NET Core, or whatever.
Is it possible to configure the above using the JS SDK, or am I going to have find another approach?
Update 23/03/21
Untested, but these are my findings so far:
App Service Plan - The plan is set using the serverFarmId property of the Site interface.
Operating system - Assuming Windows as the default, if you want a Linux app service, you change the kind property of Site from app, to app,linux.
Stack & version - In the SiteConfig interface, you have linuxFxVersion and windowsFxVersion. Again, I think the assumption is 'latest .NET' (e.g. .NET 4.8). For .NET Core 3.1, the setting looks to be DOTNETCORE|3.1.
It can be achieved using js SDK. I checked the source code and it is ok. But I don't recommend to use js sdk to do this.
Because you need to call the SDK, there are many internal logics that you need to code. This will waste a lot of your time. So I recommend you to use restapi.
The restapi method name is similar to the naming in the SDK, mainly because you can test api interfaces online to achieve the functions you want. So you can selectively choose the method you want to achieve the function you want.
Official doc
Web Apps - Create Or Update
As for your concerns, you only need to write all the configuration in json format and put it in the request body.
Tips:
First use the online interface, encode the json format, create a webapp according to your needs, and then integrate it into your code.

How to use GCP Runtime Configurator from Node.js?

I'm working on a Node.js application hosted on Google Cloud, using Google Application Engine. The app has a few settings like the following:
const TASK_BATCH_SIZE = 50;
Currently, every time we need to change some settings like that one to do some tests we need to re-deploy the app, and that happens very often. We are looking for some alternatives inside the Google Cloud ecosystem that allows us to configure our running services without needing to re-deploy.
One of the things we found in the docs was Runtime Configurator, which still seems to be a beta product. For Node.js specifically nodejs-rcloadenv is the only client library we found, but doesn't seem to support the Watcher / Waiter concepts described in the Runtime Configurator docs or any other way to subscribe to variable changes in a configuration resource.
Is Runtime Configurator the solution to our problem? Are there any other services inside the Google Cloud ecosystem, or any other library for Node.js that could help us with this?
If you want to update or to make some settings changes in the service, you need to re-delpoy the service.
You can't use Runtime Configurator as it's for Compute Engine and not for App Engine.
You can create a feature request on Google's Public Issue Tracker for your issue ( to update configurations without re-deploying the service).

Installing Application Insights as an Azure App Service Extension or via NuGet?

It's possible to install Application Insights via the extensions section in Azure App Services, but it's also possible to just install the packages via NuGet and define the APPINSIGHTS_INSTRUMENTATIONKEY application setting. You can also do both.
What is the difference?
Edit:
I have found what the differences are between installing the extension or the NuGet packages:
You can configure monitoring by instrumenting the app in either of two ways:
Run-time - You can select a performance monitoring extension when your web app is already live. It isn't necessary to rebuild or re-install your app. You get a standard set of packages that monitor response times, success rates, exceptions, dependencies, and so on.
Build time - You can install a package in your app in development. This option is more versatile. In addition to the same standard packages, you can write code to customize the telemetry or to send your own telemetry. You can log specific activities or record events according to the semantics of your app domain.
Source: https://learn.microsoft.com/en-us/azure/application-insights/app-insights-azure-web-apps#run-time-or-build-time
But what if you do both? Will there be anything beneficial about it?
But what if you do both? Will there be anything beneficial about it?
The extension detects that your app has already brought Application Insights with it and won't do anything, except dropping a profiler, which helps collect full SQL Statement in Dependencies. Without the profiler full SQL Statement won't be collected but everything else should just work fine.
(If you are using 2.3.0 or earlier of SDK or if you application is targeting old .NET Framework like 4.0, then profiler does better correlation of dependencies as well.
In short, Starting with 2.4.0 of SDK, the only advantage of installing extension on top on nuget installation is to get full SQL Statements in Dependency Telemetry.
But what if you do both? Will there be anything beneficial about it?
As you know we could install the packages via NuGet to use Application Insights .For this way, we could add custom telemetry data in my code,and monitor the telemetry data in application insights tools in Visual Studio. This will be very convenient. You could also refer to this article to add custom telemetry data.
Code in MVC Porject:
public ActionResult Index()
{
Trace.TraceInformation("my trace info Home/Index");
var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
RequestTelemetry requestTelemetry = new RequestTelemetry();
telemetry.TrackTrace("Home/Index Main");
telemetry.TrackPageView("Home/Index");
return View();
}
The telemetry data in Application insight tool:
The application insights in App Service,you can only see limited data and trends in past 24 hours. This is very convenient for you to view the main telemetry data in the app service directly. But if you want to know more details, that is not a good choose.
The most comprehensive monitor data and services are in application insight service. You could click 'View more in application insights' in App Service monitor extension to go. Or you could go to application insight service directly.
Time Range in application insight service(include custom time range).

ServiceStack web service hosting on monotouch/monodroid?

I'm currently trying to host a REST webservice on ios/android using Xamarin and monotouch/monodroid. I already successfully have a basic webserver running using HttpListener, but now I would like to host a complete webservice using ServiceStack.
monotouch/monodroid have very limited web hosting capabilities (HttpListener is basically the only way), but ServiceStack can in theory accomodate with that.
It seems to be possible as I found someone who did it: http://www.servicestack.net/mythz_blog/?p=417
The problem is that project does not work anymore on the last monotouch version, and ServiceStack seems to have removed server hosting capabilites in the monotouch/monodroid latest builds...
Xamarin have a fork of ServiceStack (https://github.com/xamarin/ServiceStack) which seems to have hosting capabilities, but the monotouch specific service hosting build does not compile, and the fork seems outdated.
Has anyone succeeded in making the ServiceStack hosting capabilities work on monotouch/monodroid? Or do you have an idea on how to make it work?
You might try this tutorial for self-hosting ServiceStack.
It looks like it will use HttpListener under the hood, but I don't know if the AppHostHttpListenerBase class will compile for MonoTouch/Mono for Android or not.
Ok so after some research, the project to allow ServiceStack self-hosting has been dropped. It had a better luck with the (old) Xamarin version (https://github.com/xamarin/ServiceStack) and could compile it and make it work somehow.
Since I need to be in sync with the latest ServiceStack version, I guess that I have no other choice than to roll my own adaptation, using the old Xamarin branch as a starting point.

Resources