Showing posts with label redis. Show all posts
Showing posts with label redis. Show all posts

Tuesday, August 30, 2016

Tips for a good ESB integration system


1. Build SOA Environment –

Share common logics around processes with exposed services.

Benefits:

Changes will be easy – If a common logic gets changed, then you would only need to deploy a service again and each process would work with the new logic.

Services logic would be shared around ALL applications – 
These days, almost every develop tool or language is able to consume a web-service. That means you can share logic easily around an organization. Use it in order to minimize duplicate code and maintenance.





2. Less-Code and Out Of The Box solutions –

More code = More complexity & maintenance. 
Use products for minimum coding, reliable solutions and support from professional vendors.
 

 

3. End-To-End Tracing –

A good BPM would always have tracing and information regarding messages being transferred in the wire.
 
Suppose message doing this route -
Application A --> Integration System --> Application B, Application C, Application D.
Make sure there's a field to identify the message in each step and each application writes to the same trace log.

Application A writes that message 12203 was created in a folder.
Integration System writes that message 12203 was taken and process started.
Integration System writes that message 12203 is now sent to Application B, Application C, Application D.
Application B writes that message 12203 was received.
etc.

Write important business and technical process data.

Many organizations use SQL Server for tracing but the innovative solution is to use ElasticSearch which includes free-text search on a huge mass of data.

Building reports for customers (based on those traces) is always a good thing because they can help with maintenance.



 

4. Cache layer for lookups –

Reading and writing to and from memory is faster than any I/O.

If many processes uses configurations or lookup values stored in SQL Server then consider an appropriate cache layer which uses memory to store data.

Redis & Memcached are classic for caching, but you can also use NoSQL solutions which stored data in memory first before being persisted (e.g couchbase).





5. XSLTs for Mapping -

DON'T write C#, Java or whatever language code in order to transform XML's.

Develop XML maps ONLY with XSLTs which can be reused in any integration tool which deals with XML transformation.


 

6. Use Stored Procedures for queries -

It's better for your application to execute stored procedure for queries, rather than sending those as text to the DB.
It's easier for a DBA to control & manage organization logic, and to avoid "BAD" queries.


 

7. Dynamic configuration –


Think deeply on every process configurations you should be able to modify on runtime without changing any code.

Don't exaggerate with dynamic configurations because it has a maintenance price. You do not want an interface with a huge number of configurations, if most of them are values which will be remain unchanged. 


 

8. Well-defined schemas –

It's important that schema nodes, elements and attributes would have real limitations (Min/Max occurs, Value types etc.).

It's possible to restrict schema field value types in many ways (int, string, regular expressions, enums etc.).

Benefits:

Data integrity – Well, that's the obvious reason. Data is more reliable on each point of entire process.

Less complexity in process
– Suppose a process need to get an e-mail address from a request message.

If schema would enforce a valid e-mail regex in that field, then there is no need
to perform this validation on process.



 

9. ASync web-services is better than Sync web-services –

If there is a possibility of consuming asynchronous web-service – ALWAYS prefer it over a synchronous web-service.

Synchronic method (Two-Way) would open a session, send a request, wait for a response and only then closes the session.

Asynchrony method (One-Way) would open a session, send a request and closes the session immediately without waiting for a response.

More sessions = More CPU and more memory usage on server.

Take this tip in mind especially with offline interfaces. In those kind of processes the execution doesn't has be immediate so entire interface can last longer. 


 

10. Avoid direct-connection between Production & Test environments –

Some organizations tend to send messages from production to test\development environments.

That's really bad because if a resource isn't available in test\development then production would be affected.
 

 

11. Identical backup environment (or clustered in an active-passive mode) –

Maintain a backup (not-activated) environment for production (an exact copy of it).

Make sure backup environment is always up to date with the latest changes of the WORKING production environment.


 

12. Retry mechanism when using resources –

Consider using retry mechanism on a process which uses resources (SQL, Web-Services etc.).

Take notice you can implement retry only on OFFLINE processes/ASync services (i.e. when no one waits with an open session for an answer from that service).


 

13. Centralized production environments -

With the major communication progress during the last few years, geographic distance is not an issue as it used to be.

Less environments = Less maintenance.

A good centralized environment contains distributed servers which share data processing.
Some integration tools like "BizTalk" includes load balancing mechanism out of the box, but if your tool doesn't - a load balancing software would help.

 

14. Health and performance monitor system –

Monitor & alert crucial resources which is used by processes to early identify issues. "SCOM" and "Nagios" are popular products. Use "Watcher" for elasticsearch logs.

For instance: 
If a server CPU stays on 100% for the last 30 seconds – send an e-mail. 
If files are piling up in a directory which should be empty – send an SMS.



 

14. Archive source messages\requests –

Gives power for an integration system to rerun messages in case process went wrong and to be self-dependent from end-to-end.



 

15. Persistence –

Some integration tools (like BizTalk, which is DB-based) have persistence functionality built-in as part of their engine.
Products that put an emphasis on performance doesn't have it (e.g TIBCO) but it's possible to implement persistence logic inside a process.
Analyze each process before implementing and think when persistence is necessary if everything breaks down.

 

16. Parallel processing –

Use parallel processing if process logic allows it but beware from over-complex.
Keep in-mind that code should be thread-safe.




Tuesday, February 16, 2016

Redis & Jedis Quickstart

Hi,

In this post I would share some commands to help you get started quickly with Redis and Jedis provider.

To get started, you can download redis installation from:
If you use windows, use MSOpenTech version from:

Jedis (Redis java provider):


Connect to redis server


redis-cli -h [host] -p [port]

(default port is 6379)

Useful commands


INFO - Prints general details about the current server

GET [Key] - Gets a value of a key

SET [Key] [Value] - Sets a value of a key

SETEX [Key] [Seconds] [Value] – Sets key & value with expiration

RENAME [OldKeyName] [NewKeyName] - Renames a key

DEL [Key] [Key] .... - Removes given keys and returns the number of keys removes

APPEND [Key] [Value] – Append a value to a key

EXISTS [Key] - Returns 1 if the given key exists, 0 if not.

KEYS [regex] - Prints all keys matches a given regex pattern

KEYS * - Prints all keys

KEYS hello* - Prints all keys that starts with "hello"

TTL [Key] – Gets the remaining time of a key to live.

TIME  [Key] – Returns the time of the current server.

DBSIZE - Number of keys in db

FLUSHALL - Removes all keys & values

SLAVEOF [host] - Creates a slave to a master

SLAVEOF NO ONE - Promotes slave to master

ROLE - Tells whether current server is master or slave

CLUSTER INFO - Prints details regarding the redis cluster parameters like state, size etc.

CLUSTER NODES - Prints details regarding servers in the cluster 

CONFIG GET  * - Prints all configuration file data

CONFIG SET [Key] [Value] - Sets a value to a config key (Can be use in runtime)

CLIENT SETNAME [This client name] – Assigns a name to the current connection

CLIENT GETNAME – Gets the current connection name

CLIENT LIST - Prints information about client connections to the current server

QUIT - Closes connections to the server


SENTINEL:


"Redis Sentinel is a distributed system:

Sentinel itself is designed to run in a configuration where there are multiple 

Sentinel processes cooperating together. The advantages of having multiple 

Sentinel processes cooperating are the following:

1. Failure detection is performed when multiple Sentinels agree about the 

fact a given master is no longer available. This lowers the probability of 

false positives.

2. Sentinel works even if not all the Sentinel processes are working, 

making the system robust against failures. There is no fun in having a 

fail over system which is itself a single point of failure, after all."

(Taken from official redis documentation http://redis.io/topics/sentinel) 


Starting a redis server in sentinel mode:

redis-server /path/to/sentinel.conf --sentinel


Setting a sentinel option:

sentinel <option_name> <master_name> <option_value>


Setting a sentinel master:

sentinel monitor <master-group-name> <ip> <port> <quorum>


All these configuration should be placed in "sentinel.conf":

sentinel monitor mymaster 127.0.0.1 6379 2

sentinel down-after-milliseconds mymaster 60000

sentinel failover-timeout mymaster 180000

sentinel parallel-syncs mymaster 1


First config row - Sentinel configuration INCLUDING master (slaves are auto-discovered).
The last value ("2") is the quorum number (number of Sentinels that need to agree about the fact the master is not reachable).

Last config row - parallel-syncs is the number of slaves which will participate in configuring the new master after failover.
(Bigger number = Faster sync, but if the data is old in some of them, it might be written to the new master)


Jedis Java Provider


Common Pool Constructors:

JedisPool(Config poolConfig, String host)


JedisPool(Config poolConfig, String host, int host)


JedisSentinelPool(String masterName, Set<String> sentinels)

Parameters:

masterName – Name of the sentinel master given in "sentinel monitor" line in 

"sentinel.conf". In the example above it's "mymaster".

sentinels - Entire set of IP addresses of all sentinels (Master + Slaves).

For Example:

HashSet<String> sentinels = new HashSet<String>();

sentinels.add("127.0.0.1:1234");

JedisSentinelPool jedisPool = new JedisSentinelPool("mymaster", sentinels);


Get key example: 

Jedis jedis = jedisPool.getResource(); 

String result = jedis.get(key);                 

jedisPool.returnResource(jedis);

Set key example: 

Jedis jedis = jedisPool.getResource(); 

jedis.setex(key,secondsTillExpired, value); // setting a key and a value with expiration

jedisPool.returnResource(jedis);



CLUSTER


Redis Cluster provides a way to run a Redis installation where data is automatically 

sharded across multiple Redis nodes.

(Taken from official redis documentation http://redis.io/topics/cluster-tutorial).

Thank you Blogger, hello Medium

Hey guys, I've been writing in Blogger for almost 10 years this is a time to move on. I'm happy to announce my new blog at Med...