shiguredd Knowledge Base
website·Indexed 29 days ago
https://shiguredd.github.io/A personal blog and documentation site covering a variety of technical topics, including Azure cloud services (SQL Server, API Management, App Service), AWS serverless architecture, React development with shadcn-ui, JavaScript, C#, and AI prompt templates for Stable Diffusion.
What's inside shiguredd
- Azure API Management is a fully managed service consisting of three primary components: an API gateway (the entry point for requests), a management plane (for configuration and administration), and a developer portal (for API documentation and consumer self-service).
Overview of Azure Compute Services
Azure provides a variety of compute options ranging from raw VMs to serverless functions:
- Azure App Service: Managed hosting for web apps, RESTful APIs, and mobile back ends.
- Azure Batch: Managed service for large-scale parallel and high-performance computing (HPC).
- Azure Container Apps: Serverless environment for containerized apps built on Kubernetes.
- Azure Container Instances (ACI): Simple way to run a single container or group of containers without managing VMs.
- Azure Functions: Event-driven serverless functions triggered by various events.
- Azure Kubernetes Service (AKS): Fully managed Kubernetes for container orchestration.
- Azure Red Hat OpenShift: Managed OpenShift clusters for production Kubernetes workloads.
- Azure Service Fabric: Distributed systems platform for microservices across Azure or on-premises.
Choose Azure compute services by architecture style and TLS handling
Select a compute service based on the intended architectural pattern (e.g., Microservices, HPC, N-tier) and how TLS is managed. For instance, AKS and Container Apps use Ingress controllers for TLS, while Virtual Machines require TLS to be configured within the VM.Service TLS Suitable Architecture Styles Virtual Machines Configured in VM N-tier, Big compute (HPC) App Service Supported Web-queue-worker Azure Functions Supported Microservices, Event-driven AKS Ingress controller Microservices, Event-driven Container Apps Ingress controller Microservices, Event-driven Container Instances Sidecar container Microservices, task automation, batch jobs Azure Red Hat OpenShift Supported Microservices, Event-driven Service Fabric Supported Microservices, Event-driven Batch Supported Big compute (HPC) Azure VMware Solution Configured in VM VM workload based on VMware format Optimize AWS Serverless Costs
Apply these strategies to reduce operational costs across the architecture:
- Lambda: Right-size memory (start at 256MB), set aggressive timeouts (30-60s), and use Reserved Concurrency to prevent cost spikes.
- Bedrock: Implement request throttling and token budgets per user. Use Claude 3 Haiku for simple tasks and Sonnet for complex ones.
- S3: Use S3 Intelligent-Tiering and lifecycle policies (Standard → IA → Glacier). Compress stored text using gzip.
- OpenSearch: Use Serverless mode and batch embedding storage operations.
- DynamoDB: Use On-Demand pricing and TTL for automatic record deletion.
Implement multi-tenancy in a serverless PDF QA architecture
To ensure data isolation in a multi-tenant serverless PDF QA system, use the following strategies:
- Identity Management: Use Amazon Cognito User Pools to isolate users.
- Database Isolation: Include the
tenant_idoruser_idas part of the DynamoDB partition key. - Search Isolation: Use a dedicated OpenSearch index per tenant or implement strict metadata filtering within a shared index.
Integrate shadcn-ui components into Docusaurus
This integration allows developers to use shadcn-ui components directly within Docusaurus documentation sites. Key capabilities include setting up the shadcn-ui library within the Docusaurus project structure, utilizing components inside MDX files for interactive documentation, creating reusable component examples, and customizing component themes to align with the documentation's visual style.Secure a serverless PDF QA architecture on AWS
Follow these security guidelines to protect data and access in a serverless PDF QA environment:
- Authentication: Use Amazon Cognito User Pools with Multi-Factor Authentication (MFA).
- Authorization: Apply the principle of least privilege using IAM roles.
- Encryption:
- S3: Use SSE-S3 or SSE-KMS.
- DynamoDB: Enable encryption at rest.
- API Gateway: Enforce TLS 1.2+.
- Isolation: Implement tenant-based data separation.
- Auditing: Enable AWS CloudTrail to log all API calls.
- Network: Use a VPC for Lambda functions if required for compliance.
Understand the Byte Pair Encoding (BPE) algorithm
Byte Pair Encoding (BPE) is a subword tokenization algorithm that iteratively merges the most frequent pair of adjacent symbols (bytes or characters) in a text corpus to create a vocabulary of subword units. This approach balances word-level and character-level representations, allowing models to handle out-of-vocabulary words by breaking them into known sub-units.
The BPE process follows these steps:
- Initialize vocabulary with individual characters and their frequencies.
- Count the frequency of all adjacent symbol pairs.
- Merge the most frequent pair into a new single symbol.
- Add the new symbol to the vocabulary.
- Repeat until the target vocabulary size is reached or no more merges are possible.
Test a Docusaurus production build locally
Before deploying to a hosting provider, you can verify the production build locally. Running the serve command will host the contents of thebuildfolder at http://localhost:3000/.npm run serveCreate standalone pages using the src/pages directory
To create a standalone page, add a Markdown or React file to the
src/pagesdirectory. The file system structure determines the URL path:src/pages/index.jsmaps to the root URL (/)src/pages/foo.mdmaps to/foosrc/pages/foo/bar.jsmaps to/foo/bar
Select Azure compute services based on availability and failover requirements
Most Azure compute services support multiregion failover via Azure Traffic Manager and Azure Front Door. Specialized services like Virtual Machines and Service Fabric also support cross-region Load Balancers. Azure Batch and Azure VMware Solution do not have native multiregion failover options listed.Service Multiregion Failover Option Virtual Machines Azure Traffic Manager, Azure Front Door, cross-region Load Balancer App Service Traffic Manager, Azure Front Door Azure Functions Traffic Manager, Azure Front Door AKS Traffic Manager, Azure Front Door, Multiregion Cluster Container Apps Traffic Manager, Azure Front Door Container Instances Traffic Manager, Azure Front Door Azure Red Hat OpenShift Traffic Manager, Azure Front Door Service Fabric Traffic Manager, Azure Front Door, cross-region Load Balancer Batch Not applicable Azure VMware Solution Not applicable Implement the RAG (Retrieval-Augmented Generation) Flow
Follow these steps to implement the Q&A flow:
- Receive user question via API Gateway.
- Use a Lambda function to generate an embedding for the question.
- Perform a vector similarity search in OpenSearch to retrieve the top 5-10 relevant document chunks.
- Construct a prompt combining the retrieved context and the user's question.
- Invoke Amazon Bedrock (Claude 3.5) to generate the final answer.
- Return the answer to the user including source citations.